Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a card via Trello fails with a 400 response

Tags:

trello

I have tried doing this via Chello (a .NET wrapper for the Trello API) and via Fiddler. In both cases I am getting back a 400 response with "invalid value for name".

Here is the request and response data. Please note I have changed the key, token, and idList for security reasons. Also the token does have read/write permission.

POST https://api.trello.com/1/cards?key=<myKey>&token=<myToken> HTTP/1.1
User-Agent: Fiddler
Host: api.trello.com
Content-Length: 115

{ 
  name: "My new card name", 
  desc: "My new card description", 
  idList: "<myIdList>" 
}

HTTP/1.1 400 Bad Request
X-Powered-By: Express
Content-Type: text/plain; charset=utf-8
Content-Length: 23
Cache-Control: max-age=0, must-revalidate
Expires: Thu, 01 Jan 1970 00:00:00
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, PUT, POST, DELETE
Connection: keep-alive

invalid value for name

Any help with this issue would be appreciated.

like image 842
Scott Smith Avatar asked Dec 20 '22 17:12

Scott Smith


1 Answers

Despite using POST, the Trello API actually expects the values to be in the query string rather than in the POST body. Your example should be more along the lines of:

https://api.trello.com/1/cards?key=<myKey>&token=<myToken>&name=My+new+card+name&desc=My+new+card+description&idList=<myIdList>

Using the code you posted, you end up with an "invalid value for name" because it is the first parameter it checks for and does not find.

like image 174
John C Avatar answered Dec 30 '22 10:12

John C