GAS cannot add more than one member when creating a new Trello card

Asked 2 years ago, Updated 2 years ago, 44 views

GAS is creating a new Trello card from Google Spreadsheet.
The Trello specification should allow you to assign more than one member to the card, but if you try to do so with GAS, you get an error.
Please let me know how to solve this problem.

error message

Exception: https://api.trello.com request failed (error: 400) Part of the server response: {"message": "Invalid objectId", "error": "ERROR"} (Use the muteHttpException option to view the full response) (line 28, file "CreateCard")

sample code

function createCard(){
  varscriptProperties=PropertiesService.getScriptProperties();
  const Trello_KEY=scriptProperties.getProperty('Trello_KEY'); // Get the key for Trello
  const Trello_TOKEN=scriptProperties.getProperty('Trello_TOKEN'); // Get Token for Trello

  const URL='https://api.trello.com/1/cards/';
  
  var payload=
      {"key" : Trello_KEY,
       "token": Trello_TOKEN,
       "idList": "XXXXXXXXXXXXXXXXXXX", // ID of the list
       "name": "Ahhhhhhhhhhhhhhhhhhhhhhh
       "idMembers": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABad specification error occurred here
      };
  
  var option=
      {"method": "POST",
       "payload"—Payload
      };
  
  UrlFetchApp.fetch(URL, option);
  
}

Also,
"idMembers":["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
the part of "idMembers":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA If you remove the array and leave only one, no errors will occur.

For Trello API references, see

idMembers
Array <string>

Comma-separated list of member IDs to add to the card

So I thought it would be better to define it as an array, but it doesn't seem to work.

I tried various other input methods, but it didn't work.Thank you for your cooperation.

google-apps-script

2022-09-30 17:28

1 Answers

The error says
Comma-separated list of member IDs to add to the card. For example, separate commas as follows:

"idMembers": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

This post was posted as a community wiki based on @Tanaike's comments.


2022-09-30 17:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.