Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

REST API PHP Curl

Hi,

I try to search for issues and display them on a website using PHP and REST API. I don't get how to build the correct curl function. Already tried this way, but i don't receive any data:

function get_issues($url){
    $jira_url = "$url;
    $curl = curl_init();
    $curl_options =  array(
        CURLOPT_URL => $jira_url,
        CURLOPT_USERPWD => "user:password"
    );
    curl_setopt_array($curl, $curl_options);
    $result = curl_exec($curl);
    echo $result;
    curl_close($curl);
}

1 answer

0 votes
John Fetzik
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2022

While I do not use PHP and haven't used curl in years, but here are a few things to double check.

First, make sur you are using an API Token and not the actual user password. See the following for details, https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/

Second, for Basic Auth you may need to encode the username/password, before using it. There is an example of this on the page linked to above.

Third, you may not have the correct URL for the REST query. You do not show which endpoint you are trying to use, so we cannot tell.

More generally have you tested this manually by running curl from a command line? You don't say in your post. If you are not already using it I would suggest using the Postman tool to test your queries. Plus Postman will generate code snippets in many "languages" including curl and PHP - curl. Check Postman API Platform

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events