Skip to main content
Solved

uapi to update Mobile Device Extension Attribute

  • August 15, 2018
  • 2 replies
  • 18 views

Forum|alt.badge.img+4

trying to get my scripting correct to be able to update an extension attribute for an ipad using rest api. even through the Try It Out feature on the uapi/docs i receive an error 500 so something isnt correct. All examples are in XML but uapi is in JSON which i prefer (as im using powershell)

as the example in the uapi docs isnt working, i know the request isnt correct.....but what am i missing? is the documentation correct? I noticed in the model schema it mentions

  "extensionAttributes": [
    {
      "id": 0,
      "name": "string",
      "type": "STRING",
      "value": "string"
    }

but in the bodies Model Schema it has

"updatedExtensionAttributes": [
    {
      "id": 0,
      "name": "string",
      "type": "STRING",
      "value": "string"
    }
  ]

here is the generated example which fails with error 500. the attribute exists, correctly as far as i know.

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: jamf-token [insert token]' -d '{
  "updatedExtensionAttributes": [
    {
      "id":1,
      "name": "DiscoProfile",
      "value": "xxx"
    }
  ],
}' 'https://[server].jamfcloud.com/uapi/inventory/obj/mobileDevice/1/update'

Best answer by SamF

It appears that your original request has an extra comma, which likely resulted in the 500 error. Your second comment indicates that you've since resolved that issue, based on the request body. However, the Jamf Pro API requires the id of the extension attribute that you're attempting to update. Try using a request body like the following:

{
  "updatedExtensionAttributes": [
    {
      "id": 1,
      "value": "xxxx"
    }
  ]
}

2 replies

Forum|alt.badge.img+4
  • Author
  • Contributor
  • August 15, 2018

OK now i can submit the POST on the uapi Try Out button. with success 200. however the response still doesnt seem to reflect the changes.
here is the data i POSTed as above

{
  "updatedExtensionAttributes": [
    {
      "name": "DiscoProfile",
      "value": "xxxx"
    }
  ]
}

and here is the appropriate chunk from the response body

"extensionAttributes": [
    {
      "id": 1,
      "name": "DiscoProfile",
      "type": "STRING",
      "value": "test"
    }
  ]

As you can see, the extension attribute is still unchanged


Forum|alt.badge.img+20
  • Employee
  • Answer
  • August 15, 2018

It appears that your original request has an extra comma, which likely resulted in the 500 error. Your second comment indicates that you've since resolved that issue, based on the request body. However, the Jamf Pro API requires the id of the extension attribute that you're attempting to update. Try using a request body like the following:

{
  "updatedExtensionAttributes": [
    {
      "id": 1,
      "value": "xxxx"
    }
  ]
}