Hello, I'm using the trello api with PHP to add, update and archive cards on a specific board.
When I want to archive cards (with archiveAllCards), I get the following error (only with this function. No errors with the rest) :
unauthorized permission requested
Do you only get that error with that function?
Have you already authorized your application using these steps? If not, you can't just start making API calls; you have to go through that process first.
Are you including the token and key in the correct order/format, as detailed here?
Without more information, it's hard to say. But an "unauthorized" error leads me to believe this has something to do with that part of the request.
I get this error only with this function yes.
Creating a new card is working for example. Getting all the cards from a list is also okay.
When creating my token, I gave the permissions read, write and account.
EDIT : updating the name of a list is also NOT working.
So getting cards, adding cards is work.
Delete cards, update name of the list, is not working
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you post what the call looks like (don't post your ACTUAL sensitive information, just indicate where it is in the call)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<?php
require_once 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/json'
);
$query = array(
'key' => 'my_api_key',
'token' => 'my_token',
);
$response = Unirest\Request::post(
'https://api.trello.com/1/lists/67a1db506b41865c9f1b9370/archiveAllCards',
$query
);
echo '<pre>';
var_dump($response);
echo '</pre>';
?>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found my mistake. I didn't include the $headers in the post call !
Unirest\Request::post(
'https://api.trello.com/1/lists/67a1db506b41865c9f1b9370/archiveAllCards',
$headers,
$query
);
Like this, it's working now.
The code in the documentation API is also incorrect in PHP (it doesn't include the headers) :
https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-archiveallcards-post
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So glad to hear it! Let me know if I can be of further assistance. Sometimes all it takes is a rubber duck!
I think headers are assumed after they are explained in the documentation, which can be confusing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The API call needs to be a POST call and look like this:
https://api.trello.com/1/lists/<listId>/archiveAllCards?key=<key>&token=<token>
I've just tested on a Test-board of mine and there it worked as expected
Also make sure your token is a read/write token (but given your can add cards that should be covered)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.