Skip to main content

Hi,

I once again having issues using the new API / UAPI / Jamf Pro API.

Getting error: "httpStatus" : 405, for which I cannot find description here: https://developer.jamf.com/jamf-pro/docs, anybody knows what it is?

What I am trying to do is simply change computer's Site on JSS via the new API, any input would be appreciated ($id is current computer ID on JSS):

curl -X PATCH "https://jss.MYCOMPANY.com:8443/uapi/v1/computers-inventory/$id" -H "accept: application/json" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d "{\\"general\\":{\\"site\\":[{\\"id\\":\\"6\\"}]}}"

I have tried it using Site name as well:

curl -X PATCH "https://jss.MYCOMPANY.com:8443/uapi/v1/computers-inventory/$id" -H "accept: application/json" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d "{\\"general\\":{\\"site\\":[{\\"name\\":\\"EMEA - London\\"}]}}"

 

same error, the problem I suspect is with this: "{\\"general\\":{\\"site\\":[{\\"name\\":\\"EMEA - London\\"}]}}", for which I can't find anything, I have tried to build it here, but can't find Site for some reason o-O: https://developer.jamf.com/jamf-pro/reference/computer-inventory-1#patch_v1-computers-inventory-detail-id

As the Jamf Pro API uses HTTP this is an HTTP.

HTTP 405 errors are caused when an HTTP method is not allowed by a web server for a requested URL. This condition is often seen when a particular handler has been defined for a specific verb, and that handler is overriding the handler that you expect to process the request.


@Phantom5, thatnks for the info, it is a bit confusing though.... per: https://developer.jamf.com/jamf-pro/reference/computer-inventory-1#patch_v1-computers-inventory-detail-id

I can see that there is site (see attachment please), but when trying to add it in various ways I receive 405.

 

The path per what I see in the reference - "{\\"general\\":{\\"site\\":{\\"name\\":\\"EMEA - London\\"}}}" - looks correct to me, I have tried it with additional brackets, but getting the same error...:

curl -X PATCH "https://jss.MYCOMPANYcom:8443/uapi/v1/computers-inventory/$id" -H "accept: application/json" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d "{\\"general\\":{\\"site\\":{\\"name\\":\\"EMEA - London\\"}}}"

Am I not putting the right path after -d?


@Phantom5, thatnks for the info, it is a bit confusing though.... per: https://developer.jamf.com/jamf-pro/reference/computer-inventory-1#patch_v1-computers-inventory-detail-id

I can see that there is site (see attachment please), but when trying to add it in various ways I receive 405.

 

The path per what I see in the reference - "{\\"general\\":{\\"site\\":{\\"name\\":\\"EMEA - London\\"}}}" - looks correct to me, I have tried it with additional brackets, but getting the same error...:

curl -X PATCH "https://jss.MYCOMPANYcom:8443/uapi/v1/computers-inventory/$id" -H "accept: application/json" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d "{\\"general\\":{\\"site\\":{\\"name\\":\\"EMEA - London\\"}}}"

Am I not putting the right path after -d?


Just as an fyi, this for example works fine:

#curl -X PATCH "https://jss.MYCOMPANTY.com:8443/uapi/v1/computers-inventory-detail/$id" -H "accept: application/json" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d "{\\"extensionAttributes\\":[{\\"definitionId\\":\\"67\\",\\"values\\":[\\"$currentlocaladminpass\\"]}]}"

 

I can't seem to find what I am doing wrong when trying to change the Site in similar way...


Just as an fyi, this for example works fine:

#curl -X PATCH "https://jss.MYCOMPANTY.com:8443/uapi/v1/computers-inventory-detail/$id" -H "accept: application/json" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d "{\\"extensionAttributes\\":[{\\"definitionId\\":\\"67\\",\\"values\\":[\\"$currentlocaladminpass\\"]}]}"

 

I can't seem to find what I am doing wrong when trying to change the Site in similar way...


Try using curl -i instead of -X


Try using curl -i instead of -X


Still getting 405, with a little more info:

curl: (6) Could not resolve host: PATCH HTTP/1.1 405 Expires: 0 Cache-Control: no-cache, no-store, must-revalidate X-XSS-Protection: 1; mode=block Strict-Transport-Security: max-age=31536000 ; includeSubDomains X-Frame-Options: DENY Content-Type: application/json Transfer-Encoding: chunked Date: Mon, 06 Sep 2021 15:44:59 GMT Server: Apache Tomcat { "httpStatus" : 405, "errors" : [ ] }

What's interesting is that when I tried -i with the "{\\"extensionAttributes\\":[{\\"definitionId\\":\\"67\\",\\"values\\":[\\"$currentlocaladminpass\\"]}]}" example - it no longer works, once again with the 405 error o-O, so it is even more strange, -X does work with this example and not with -i, but where I want to change the Site: both -i and -X fail with 405


As the Jamf Pro API uses HTTP this is an HTTP.

HTTP 405 errors are caused when an HTTP method is not allowed by a web server for a requested URL. This condition is often seen when a particular handler has been defined for a specific verb, and that handler is overriding the handler that you expect to process the request.


It is strange that I get the "HTTP 405 errors are caused when an HTTP method is not allowed by a web server for a requested URL" error, since it works for adjusting extension attribute, but does not allow adjusting the Site...


I have tried using the exact syntax for the UAPI such as:

 

 

curl --request PATCH \\ --url "https://jss.MYCOMPANY.com:8443/uapi/v1/computers-inventory-detail/$id" \\ --header "Accept: application/json" \\ --header "Authorization: Bearer $token" \\ --header "Content-Type: application/json" \\ --data ' { "general": { "site": { "name" : "APAC - Bangalore" } } } '

 

 

And I am getting: " "httpStatus" : 400,
"errors" : [ {
"code" : "INVALID_CONTENT",
"description" : "Unrecognized field \\"site\\" (class com.jamfsoftware.computersinventory.api.update.ComputerGeneralUpdateDto), not marked as ignorable","

 

How can it not find it if it is at the same place as "extensionAttributes" - underneath "general"...


Nevermind, PATCHing site is simply not available yet 😞

 

"The PATCH endpoint does not currently support the ability to update the site of a device. The right column where you're referencing the site element is the expected response to a PATCH request, not the request itself. The center column defines allowable elements to the request body, which you'll see sites are not listed. I'd recommend filing a feature request, if one does not already exist."


I'm looking to implement a process like this in our ITSM solution.  Did you every find a resolution to this?