Pascal Klein
Pascal Klein

Reputation: 24863

Trello Api: Create new Card out of PHP Code

I would like to create a new Trello Card when a new User signs up for our webapplication.

To do that I requested a "read,write" Token (lets name it "myToken" ) for my user and I have my application key (lets name it "myKey").

Because I could not find any PHP-Wrapper I first used Fiddler to test the HTTP-Post request. Specifically I tried the following:

HTTP-POST

URL: 
http://api.trello.com/1/cards

Request-Headers: 
User-Agent: Fiddler
Host: api.trello.com
Content-Length: 177

Request Body:
key=myKey&token=myToken&name=newCardName&desc=newCarddescription&idList=myListId

However this doesnt work. I get back an HTML-Code, that shows a website which tells the user to login! What am I doing wrong?

Upvotes: 4

Views: 6606

Answers (1)

Pascal Klein
Pascal Klein

Reputation: 24863

Thanks @Daniel LeCheminant. I made two mistakes:

1.) I used http instead of https 2.) I put the variables in the request body. Even though it is a post request, trello expects the variables in the url itself

This solution works for me:

https://api.trello.com/1/cards?key=myKey&token=myToken&name=newCardName&desc=newCarddescription&idList=myListId

Upvotes: 4

Related Questions