These headers look a bit weird. If you look at the example provided in the API docs:
$headers = array(
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Bearer' => '<access_token>'
);
You will notice that the ‘Content-Type’ differs from your implementation. The Bearer header is not applicable, since you have chosen for Basic Auth. So you can remove that header, and replace it with the ‘Authorization’ => 'Basic '.$tokenEncoded
header.
Now, given that you have already provided the Authorization header, you do not also have to add
// basic auth
Unirest\Request::auth(‘hellodolly@bingo.com’,‘sometokenhuh’);
However, because you are receiving a 415 method not allowed and not a 401, it seems like the authentication is not the issue. So my best bet would be the fact that the Content-Type
and Accept
headers are malformed.
Can you try with this:
require_once('vendor/autoload.php');
require_once('vendor/mashape/unirest-php/src/Unirest.php');
$token = 'hellodolly@bingo.com:sometokenhuh';
$tokenEncoded = base64_encode($token);
//var_dump($tokenEncoded);
$headers = array(
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Basic '.$tokenEncoded
);
$body = <<<REQUESTBODY
{
"visibility": {
"type": "role",
"value": "jira-software-users"
},
"body": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Bacon ipsum dolor amet deserunt ham hock picanha magna ground round swine. Bresaola andouille lorem in sunt cupidatat velit boudin in tenderloin kevin kielbasa ham minim ea. ",
"type": "text"
}
]
}
]
}
}
REQUESTBODY;
$response = Unirest\Request::post('https://wubbalubbadubdub.atlassian.net/rest/api/3/issue/BBB-835/comment', $headers, $body);
var_dump($response);