What url should I use to create issue on jira ondemand via php?

I've tried this code (it's just a piece) but it didn't work, with local JIRA it works fine.

I think I use wrong url for jira's rest api.

What api's url should I use?

Thanx in advance.

define('JIRA_URL', 'https://"myinstance".atlassian.net');
define('USERNAME', 'myuser');
define('PASSWORD', 'mypassword');

function post_to($resource, $data) {
    $jdata = json_encode($data);
    $ch = curl_init();
    curl_setopt_array($ch, array(
        CURLOPT_POST => 1,
        CURLOPT_URL => JIRA_URL . 'rest/api/latest' . $resource,
        CURLOPT_USERPWD => USERNAME . ':' . PASSWORD,
        CURLOPT_POSTFIELDS => $jdata,
        CURLOPT_HTTPHEADER => array('Content-type: application/json'),
        CURLOPT_RETURNTRANSFER => true
    ));

3 answers

0 votes

Looks like you've used a simple direct hit on the UI, not REST.

Have a look at https://confluence.atlassian.com/display/DOCSPRINT/The+Simplest+Possible+JIRA+REST+Examples - there's not a php example, but plenty of others that will give you a good idea.

Thanx for the answer.

But my code works fine with JIRA that I have on my PC, with 'localhost' instead of 'https//myinstance.atlassian.net' everything goes ok.

I think the problem is with the port, I had timeout error with 443, maybe I should try another one?

There's nothing wrong with using port 443 - that's for https traffic, which you need to use for OnDemand/Cloud anyway. I suspect your localhost is working over http?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,826 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot