1

I'm trying to call the API of JIRA via PHP's cURL but I can't make the PUT/DELETE methods to work. cURL cli from linux work. Example:

curl -u user:pass -X PUT -H "Content-Type: application/json" --data '{"fields": {"summary": "[Test] Testing REST API!"}}' http://jirahost.com/rest/api/2/issue/testIssue

My PHP code:

curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);                                  
curl_setopt($curl, CURLOPT_USERPWD, $jirauser . ":" . $jirapass);
curl_setopt($curl, CURLOPT_URL, $jirahost . "issue/testIssue");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $data)
print_r(curl_exec($curl));

My cURL options are right, 'casue GET/POST requests work.

Nikhil Vaghela
  • 2,088
  • 2
  • 15
  • 30
dzervas
  • 250
  • 2
  • 14
  • `"Doesn't work"` -- Please elaborate. What error do you get? – Tom Lord Sep 05 '16 at 11:26
  • 1
    No errors. `curl_exec` just returns `NULL` and the issue is not updated Also keep in mind that I don't have access to the JIRA logs. – dzervas Sep 05 '16 at 12:22
  • 1
    What happens if you try: `curl_setopt($curl, CURLOPT_VERBOSE, true)`? This prints debug to STDERR; you can also have it write to a log file if you prefer: http://stackoverflow.com/questions/3757071/php-debugging-curl – Tom Lord Sep 05 '16 at 12:28
  • Thank a million. I am using slim framework and I forgot to add the `$args` so I was passing to the wrong URL. – dzervas Sep 05 '16 at 14:09

0 Answers0