Skip to main content
Question

API JSON output possibly missing keys


Forum|alt.badge.img+9

I'm having trouble with the API and making changes with JSON.

First, it's confusing because when looking at https://jamf.domain.com:8443/API and testing /mobiledeviceapplications, the output JSON looks to be missing keys when compared to the XML version.

In this pic, you can see that the XML returns a <mobile_device_group> element for each group inside the <mobile_device_groups> element. In the JSON version, the mobile_device_group key is missing and the groups are directly underneath the mobile_device_groups key.

Second, when it comes to sending data to /mobiledeviceapplications, I can get XML to work, but not JSON. In my JSON tests, I've tried with the mobile_device_group key added and removed, but neither work.

Here's the tests I'm using:

jssuser="jssuser"
jsspass="jsspass"
jssserver="https://jamf.domain.com:8443"


#WORKING XML
curl -k -s -u $jssuser:$jsspass -X PUT -H "Content-Type: application/xml" -H "Accept: application/xml" -d '<?xml version="1.0" encoding="UTF-8" ?><mobile_device_application><scope><mobile_device_groups><mobile_device_group><id>883</id></mobile_device_group><mobile_device_group><id>128</id></mobile_device_group></mobile_device_groups></scope></mobile_device_application>' $jssserver/JSSResource/mobiledeviceapplications/id/171


#NON-WORKING JSON WITH mobile_device_group
curl -k -s -u $jssuser:$jsspass -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -d '{"mobile_device_application": {"scope": {"mobile_device_groups": {"mobile_device_group": [{"id": "883","name": "+test+"},{"id": "128","name": "+tech+"}]}}}}' $jssserver/JSSResource/mobiledeviceapplications/id/171


#NON-WORKING JSON WITHOUT mobile_device_group
curl -k -s -u $jssuser:$jsspass -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -d '{"mobile_device_application": {"scope": {"mobile_device_groups": [{"id": "883","name": "+test+"},{"id": "128","name": "+tech+"}]}}}' $jssserver/JSSResource/mobiledeviceapplications/id/171

Can anyone shed some light on the issue? Are we not able to do API PUTs with JSON or is there a bug in the API?

4 replies

Forum|alt.badge.img+10
  • Valued Contributor
  • 224 replies
  • October 9, 2019

You can get JSON from the API but it will not accept it.


Forum|alt.badge.img+14
  • Honored Contributor
  • 862 replies
  • October 9, 2019

What @Asnyder said.

To use JSON for sending to the API you need to use the new Jamf Pro API that is not quite complete (they are still building it out), which doesn't use XML. https://jamf.domain.com:8443/uapi/doc/


Forum|alt.badge.img+9
  • Author
  • Contributor
  • 79 replies
  • October 9, 2019

Thanks for the info, guys! That’s what I needed to know!


Forum|alt.badge.img+9
  • Author
  • Contributor
  • 79 replies
  • October 9, 2019

I guess there one more thing still...
In the first part of my issue I mentioned that the JSON output is not showing the mobile_device_group key. Is this a bug? Because converting the json to xml will not include the missing key and therefor fail when used by the api.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings