API PUT.. what am I doing wrong??

kerouak
Valued Contributor

Runs but doesnt replace the value in the following <string>often</string> to <string>unset</string>

>>
apiUsername="myuser"
apiPassword="mypass"
jssURL="myurl"
policyID=239

curl -sS -k -u $apiUsername:$apiPassword https://myjssurl/JSSResource/managedpreferenceprofiles/id/$policyID -H "Content-Type: text/xml" -d "<managed_preference_profile><dict><key>idleTime</key><dict><key>state</key><string>unset</string><key>value</key><integer>900</integer></dict></dict></managed_preference_profile>" -X PUT

anyone see my 'obvious' mistake??

Thanks

1 REPLY 1

SamF
Contributor II
Contributor II

The body of the request is missing a bunch of the XML. At minimum, you'll need something like the following:

<managed_preference_profile>
    <general>
        <plist>XML DATA</plist>
    </general>
</managed_preference_profile>

Additionally, you will likely need to encode the XML as described in this KB article. Since you're required to PUT/POST XML to the API and the element name is "plist" it's confusing to the API what is part of the managed preference payload body and what's part of the configuration for the managed preference (within Jamf Pro), this encoding solves that problem.