API Call Syntax error

dywane
New Contributor II

Question? Has Jamf changed his Classic API Syntax? 

Example: When making a simple get Command using the following syntax 

curl -su example:exmaple -H "accept: text/xml" https://example.jamfcloud.com/JSSResource/computers/

I get the following error message: 

<title>Status page</title>

</head>

<body style="font-family: sans-serif;">

<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Unauthorized</p>

<p>The request requires user authentication</p>

<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">here</a>.<br>

Please continue your visit at our <a href="/">home page</a>.

</p>

</body>

</html>%                        

However if I just cut and past from the try this out I notice that url now has a bearer token attached to the end.

Example curl -X 'GET' \ 'https://example.jamfcloud.com/JSSResource/computers' \ -H 'accept: application/xml'

I don't see the deference!? ¯\_(ツ)_/¯

 

3 REPLIES 3

sdagley
Esteemed Contributor II

@dywane Basic Auth is no longer supported for calling the Classic API and you will need to use Bearer Token auth instead. See this article from @talkingmoose for more details: https://community.jamf.com/t5/tech-thoughts/how-to-convert-classic-api-scripts-to-use-bearer-token/b...

You might also want to take a look at https://www.jamf.com/blog/understanding-jamf-pro-api-roles-and-clients/ which covers the newer API Roles and Clients mechanism.

 


@sdagley wrote:

@dywane Basic Auth is no longer supported for calling the Classic API and you will need to use Bearer Token auth instead. See this article from @talkingmoose for more details: https://community.jamf.com/t5/tech-thoughts/how-to-convert-classic-api-scripts-to-use-bearer-token/b...

You might also want to take a look at https://www.jamf.com/blog/understanding-jamf-pro-api-roles-and-clients/ which covers the newer API Roles and Clients mechanism.


Thanks for solving the syntax error. I also face this issue.

dywane
New Contributor II

Thank you! This answer explains a lot! However, now Im getting the following error message.

{

"httpStatus" : 401

"error": [] 

}

Does this error mean I have to set password policy on the Jamf instance?