What is the difference between 'trello.com' and 'api.trello.com' from the API perspective?
Asked by Fagotto San:

Hello,

So lately I've been trying to shoot up my little tool with the API, but I've run into some obstacles.

First I found a tutorial which seemly is outdated and I can't find that page again, maybe it was shut down I am so confused I don't even know.

So to point out the problem, I've tried using simply the '<https://trello.com/1/> ... base as the api and I could get card details without any problem but I've run into obstacles if I tried to update a card's details with PUT. I had the correct permission and authentication, the fact that I could get information from a card could indicate that.

Anyways, I tried to follow the new? api documentation but I saw that the base for the api url had changed to '<https://api.trello.com/1/>' and then I can't make it work again.

After the authorization I get a token with the same length, I use everything the same way (with checking the new? api documentation constantly) but it just not works. The results are different, if I use my api key in the url then it says invalid token, if I don't it says unauthorized ...

If any of this make sense for someone, can you help me point to a direction where I can smash my head into a wall and realize I'm a retarded?  
Or if anything happened with the API lately and it's just a momentarily thing (which i doubt tho) and that causes these problems.

If needed, I will provide detailed urls and messages, but using the examples from the api doc and 'Trying out' stuff failing as well.

Thank you very much.


Answers:
author: Fagotto San
body: So I tried to do it again with the old 'api'-less url and here are the results:

**<https://trello.com/1/cards/my_card_id/desc?value=some_text>**

in the request body I put the followings:
>
> ```
>
> token=token_from_authorization
> key=my_api_key
> ```

For this setup I get "Invalid key", if I remove the key from the list it stills the same.

If I'm not using the request body and use the following url:

**[https://trello.com/1/cards/my_card_id/desc?value=some_text\&key=my_api_key\&token=token_from_authorization](https://trello.com/1/cards/my_card_id/desc?value=some_text&key=my_api_key&token=token_from_authorization)**Result: "Invalid key"

The key/token has to be valid since I got through the authorization and got token data from a user and could get a card description.

Do you have any idea what is wrong with my urls or data?

Edit:

Another try with mixed order of parameters in the url:

* **[https://trello.com/1/cards/my_card_id/desc?token=token_from_authorization\&value=some_text](https://trello.com/1/cards/my_card_id/desc?token=token_from_authorization&value=some_text)** *Result: 'Invalid key'*
* **[https://trello.com/1/cards/my_card_id/desc?token=token_from_authorization\&key=my_api_key\&value=some_text](https://trello.com/1/cards/my_card_id/desc?token=token_from_authorization&key=my_api_key&value=some_text "https://trello.com/1/cards/my_card_id/desc?token=token_from_authorization&key=my_api_key&value=some_text")** *Result 'Invalid token'*
* **[https://trello.com/1/cards/my_card_id/desc?key=my_api_key\&value=some_text\&token=token_from_authorization](https://trello.com/1/cards/my_card_id/desc?key=my_api_key&value=some_text&token=token_from_authorization "https://trello.com/1/cards/my_card_id/desc?key=my_api_key&value=some_text&token=token_from_authorization")** *Result: 'Unauthorized card permission requested'*   
  *Just to back up I have permission (copied from trello settings):*

  ```

  read and write access on all your boards
  read and write access on all your teams
  Approved: today at 9:27 PM
  Never Expires
  ```

comments: author: Oscar Triscon
body: Try this instead:

Issue a PUT request to

```
https://trello.com/1/cards/my_card_id/desc?key=my_api_key&token=token_from_authorization
```

with payload:

```
{ "value": "some_text" }
```

and a header with:

```
 Content-Type: application/json
```

If this still returns Invalid key, it's most likely because the format of the key is wrong.

Make sure you're not reversing the key and the token. The API key is 32 hexadecimal characters and the token is 64 hexadecimal characters.


author: Fagotto San
body: I've seen this statement in which the token is longer than the API key, but for me they are the same length.

I am getting the key from the user through this url:

[https://trello.com/1/authorize?key=my_api_key\&](https://trello.com/1/authorize?key=my_api_key&)...

After the user clicks on Allow, a screen with 32 bit hex token appears in which it says:
> You have granted access to your Trello information.  
> To complete the process, please give this verification code:  
> 4ebcc7dd27fde13868433c5fbc3a2dc2

(the token is useless now)

And as I've said earlier getting card/member information isn't a problem at all with said token.

Also I tried the PUT request as you've suggested and the result is:
> invalid token


author: Oscar Triscon
body: You need to make sure your authorization response is a token, not a verification code:

[https://trello.com/1/authorize?expiration=never\&scope=read,write,account\&](https://trello.com/1/authorize?expiration=never&scope=read,write,account&)**response_type=token**\&name=My%20App%20Name\&key=APP_KEY


author: Fagotto San
body: Wonderful, it seems I somehow had in the authorization url the 'callback_method=postMessage' which I can see now why it caused the problem.

After deleting said parameter I got the 'Please give ... token' instead of verification.

Thank you for your help and sorry for this nonsense.

PS:

The card update works flawlessly.


author: Oscar Triscon
body: Great! Glad we could figure it out.


author: Oscar Triscon
body: <https://trello.com/1> is still working perfectly fine, and I haven't heard anything from Trello about any changes there. It's true that the new documentation has some mentions of api.trello.com but most of the examples are <https://trello.com>. The documentation was released recently and seems to have a few bugs.

I'm certain your problem arises from elsewhere. I would go back to using trello.com and making sure that the PUT request has a valid payload.

If you give me more details about your requests and responses I may be able to help.

comments: author: Fagotto San
body: Thank you Oscar, I will put everything under knife again tomorrow and try to focus on getting the <https://trello.com/1> work with PUT.


Tags: api

rest-api