I'm trying to create a new issue using the PHP example in the API docs. I've copied the code pretty much exactly; just edited a few field names. But I keep getting this error from curl:
Response from creating abc123: {"errorMessages":["Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value\n at [Source: org.apache.catalina.connector.CoyoteInputStream@2173bded; line: 10, column: 42]"]}
Here's my code; can anyone help me out here?
<?php
$vId = "abc123";
$body = <<<REQUESTBODY
{
"fields": {
"summary": "WhiteHat: test",
"issuetype": {
"id": "10041"
},
"customfield_10104": "$vId",
"customfield_10105": "5",
"customfield_10107": "www.mysite.com,
"customfield_10108": "www.mysite.com/register",
"project": {
"id": "10037"
},
"description": "Testing creation",
"reporter": {
"name": "Jira Monkey"
},
"environment": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "environment",
"type": "text"
}
]
}
]
}
}
}
REQUESTBODY;
$ch = curl_init();
$url = "https://mysite.atlassian.net/rest/api/3/issue";
$headers = array(
"Content-Type:application/json",
"Accept:application/json",
"Authorization: Basic <my_key>"
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_POSTFIELDS, $body);
//execute post
$result = curl_exec($ch);
$array = json_decode($result,TRUE);
error_log("+++Response from creating $vId: " . print_r($result, 1));
curl_close($ch);