Hi everyone! Hope you're all fine,
I'm trying to perform some automations over my Jira and right now I'm using PHP to perform an API REST call to return ASSETS
The documentation I use is this: AQL API REST
The PHP code sample given in the documentation uses the Unirest library
Anyway, this is the first time I try to perform and API call using PHP
I have done this before in Python 3 and have worked (using the Requests library)
The PHP project that I'm working with it uses the CURL setpot function to perform API calls
So, this is the situation, and current code:
Situation: I have an ASSET called Books, and there are over 25 of it, so, I have to use the PAGE param (because AQL API calls only retrieve 25 ASSETS, starting in PAGE 1) and iterate until I get all of the Books
Current code: The logical is right, and the PAGE param increases with each iteration and stops when reach the total number of Books, but, the API call ignores the param, so, the PAGE 1 is retrieved multiple times...
The code (I'm not putting the while cycle that I use to not make it longer, just the API call)
$assets_page = 1;
$ch = curl_init();
curl_setopt_array($ch, array
(
CURLOPT_URL => 'https://api.atlassian.com/jsm/assets/workspace/xxxx-xxxx-xxxx-xxxx/v1/aql/objects?qlQuery=objectSchemaId=1%20AND%20objectTypeId=1',
CURLOPT_USERPWD => 'username:token',
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "{\"page\":".$assets_page."}",
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
CURLOPT_RETURNTRANSFER => true
)
);
$result = curl_exec($ch);
curl_close($ch);
$decoderesult = json_decode($result);
print_r($decoderesult);
If anyone has any idea of how to make, it would be quite apreciatte it
Thanks in advance
Best regards,
I found the solution
If anyone interested, the thing was to
$assets_page = 1;
$ch = curl_init();
curl_setopt_array($ch, array
(
CURLOPT_URL => 'https://api.atlassian.com/jsm/assets/workspace/xxxx-xxxx-xxxx-xxxx/v1/aql/objects?qlQuery=objectSchemaId=1%20AND%20objectTypeId=1&page='.strval($assets_page),
CURLOPT_USERPWD => 'username:token',
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
CURLOPT_RETURNTRANSFER => true
)
);
$result = curl_exec($ch);
curl_close($ch);
$decoderesult = json_decode($result);
print_r($decoderesult);
Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.
Register today!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.