I am trying to pass a Bearer token (variable $token)to invoke a job via curl command. However the single quote after the -H is not letting the value of variable $token being passed to curl command.
curl -X POST 'https://server.domain.com/v2/jobs/28723316-9373-44ba-9229-7c796f21b099/runs?project_id=aff59748-260a-476e-9578-b4f4a93e7a92' -H 'Content-Type: application/json' -H 'Authorization: Bearer $token -d { "job_run": {} }'
I get this error:
{"code":400,"error":"Bad Request","reason":"Bearer token format is invalid. Expected: 'Bearer '. Received: 'Bearer $token -d { "job_run": {} }'.","message":"Bearer token is invalid."}
I tried adding like the escape character with the variable $token:
curl -X POST 'https://server.domain.com/v2/jobs/28723316-9373-44ba-9229-7c796f21b099/runs?project_id=aff59748-260a-476e-9578-b4f4a93e7a92' -H 'Content-Type: application/json' -H 'Authorization: Bearer "\$token\" -d { "job_run": {} }'
I get the same error: {"code":400,"error":"Bad Request","reason":"Bearer token format is invalid. Expected: 'Bearer '. Received: 'Bearer "\$token\" -d { "job_run": {} }'.","message":"Bearer token is invalid."}
I tried double quotes as well, it has been a few hours and I am unable to extract he variable value $token within single quotes.
Could some please assist and give me the correct syntax?
Thanks in advance