Any of the listed authentication credentials are missing

I am going to Enroll a contact into a workflow using HS API using the following code.

$header = array(

‘Authorization: Bearer’. $apiKey,

‘Content-Type: application/json’

);

$endpoint = “https://api.hubapi.com/automation/v2/workflows/$workflowId/enrollments/contacts/$contactId”;

$ch = curl_init($endpoint);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘POST’);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

$response = curl_exec($ch);

But I get the error shown below.

{"status":"error","message":"Any of the listed authentication credentials are missing","correlationId":"7bfbe7d9-1038-476b-89cd-e8abd91e69dc","engagement":{"oauth-token":"oauth-token not engaged. OAuth access token not found in request header.","hapikey":"hapikey not engaged. hapikey is not present in query params.","service-to-service":"service-to-service not engaged. Metadata for service-to-service request not found.","internal-cookie":"internal-cookie not engaged. Cookie not found in the request.","app-cookie":"app-cookie not engaged. App cookie is not present on the request."}}

Any idea on this issue? Highly appreciate your ideas.

Hey @dmadusanka,

That looks to be an issue with how you are passing through your access_token. Looking at your code I think the issue lies with how the $apikey is being concatenated.

$header = array(
'Authorization: Bearer'. $apiKey,
'Content-Type: application/json'
);

can you update to the below and try:

$header = array(
'Authorization: Bearer '. $apiKey,
'Content-Type: application/json'
);

Notice I added a space after “Bearer”.