我试图通过PHP的cURL调用JIRA的API,但是我无法使PUT / DELETE方法起作用。来自linux的cURL cli工作。 示例:
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
我的PHP代码:
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));
我的cURL
选项是正确的,' casue GET/POST
请求有效。