Ilya Bibik
Ilya Bibik

Reputation: 4114

Trello API Post new card error - Failed to execute 'postMessage' on 'DOMWindow'

I am trying to follow a tutorial and to create a new card in my Trello board list.

I am getting my key from here https://trello.com/app-key Following this tutorial https://developers.trello.com/get-started/start-building I have my board open in separate tab. And tried both public and private mode.

However, I am getting

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null').

What could be the problem?

This is my code:

  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>

  <script src="https://api.trello.com/1/client.js?key=MyKey"></script>



  <body>
     <script>




       var authenticationSuccess = function() { console.log('Successful authentication'); };
       var authenticationFailure = function() { console.log('Failed  authentication'); };


Trello.authorize({
    type: 'popup',
    name: 'Getting Started Application',
    scope: {
    read: true,
    write: true },
    expiration: 'never',
    success: authenticationSuccess,
    error: authenticationFailure
});

  var myList = 'Mylist';
  var creationSuccess = function(data) {
  console.log('Card created successfully. Data returned:' + JSON.stringify(data));
};

  var newCard = {
  name: 'New Test Card', 
  desc: 'This is the description of our new card.',
  // Place this card at the top of our list 
  idList: myList,
  pos: 'top'
};

Trello.post('/cards/', newCard, creationSuccess);

  </script>

Upvotes: 2

Views: 738

Answers (1)

Ilya Bibik
Ilya Bibik

Reputation: 4114

I figured out the problem.You have to execute it from server and not from local file system. It was that simple.

Upvotes: 1

Related Questions