Posted on 07-23-2019 12:58 AM
We are trying to create a new mobile device configuration profile.
From what I can see in https://developer.jamf.com/#/mobiledeviceconfigurationprofiles/createMobileDeviceConfigurationProfileById (by the way there is a mismatch between the example and the model. Example uses configuration_profile as root node and model call it mobile_device_configuration_profile, we had tried both without success)
So we are doing POST to /JSSResource/mobiledeviceconfigurationprofiles/id/0
sending the following body (we are trying to create a configuration profile which will create an airplay white list and scope it to a given device (10)):
<?xml version="1.0" encoding="utf-8"?>
<configuration_profile>
<general>
<name>API airplay whitelist 50:32:37:ab:6d:6d</name>
<deployment_method>Install Automatically</deployment_method>
<payloads>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1">
<dict>
<key>PayloadUUID</key>
<string>B1E156F0-AD1E-11E9-ACAC-697FF5EF5825</string>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadOrganization</key>
<string>XXXXXXXXXXXX</string>
<key>PayloadIdentifier</key>
<string>B1E156F0-AD1E-11E9-ACAC-697FF5EF5825</string>
<key>PayloadDisplayName</key>
<string>Airplay testing 1</string>
<key>PayloadDescription</key><string/>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadEnabled</key><true/>
<key>PayloadRemovalDisallowed</key><true/>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadUUID</key>
<string>B1E17E00-AD1E-11E9-ACAC-697FF5EF5825</string>
<key>PayloadType</key>
<string>com.apple.airplay</string>
<key>PayloadOrganization</key>
<string>XXXXXXXXXXXX</string>
<key>PayloadIdentifier</key>
<string>A1AD9C76-D9ED-43EC-BB2B-6031892B4EB8</string>
<key>PayloadDisplayName</key>
<string>com.apple.airplay</string>
<key>PayloadDescription</key><string/>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadEnabled</key><true/>
<key>Whitelist</key>
<array>
<dict>
<key>DeviceID</key>
<string>50:32:37:ab:6d:6d</string>
</dict>
</array>
</dict>
</array>
</dict>
</plist>
</payloads>
</general>
<scope>
<mobile_devices>
<mobile_device>
<id>10</id>
</mobile_device>
</mobile_devices>
</scope>
</configuration_profile>
We are getting:
<html> <head> <title>Status page</title> </head> <body style="font-family: sans-serif;"> <p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Bad Request</p> <p>Error in XML file. Possible mismatch between resource specified in the URL and XML file</p> <p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">here</a>.<br> Please continue your visit at our <a href="/">home page</a>. </p> </body> </html> "', error: '<html> <head> <title>Status page</title> </head> <body style="font-family: sans-serif;"> <p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Bad Request</p> <p>Error in XML file. Possible mismatch between resource specified in the URL and XML file</p> <p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">here</a>.<br> Please continue your visit at our <a href="/">home page</a>. </p> </body> </html>
I would need to know which xml I need to send to create a mobile device configuration profile and scope it to some devices (given their ids)
Regards
Posted on 07-23-2019 06:54 AM
You've got 2 XML declarations in your POST.
Sam Fortuna posted up a package with templates for the API to use with tools like POSTMAN or PAW on the jamf-api Slack channel. The template from that as a cURL is:
curl -X "POST" "https://urlJSSResource/mobiledeviceconfigurationprofiles/id/:id"
-H 'Content-Type: text/plain; charset=utf-8'
-d $'<configuration_profile>
<general>
<name>WiFi</name>
<description/>
<site>
<id>-1</id>
<name>None</name>
</site>
<category>
<id>-1</id>
<name>No category assigned</name>
</category>
<uuid>b5b6e118-b73c-4aab-bdfd-0f281a1e5fe6</uuid>
<deployment_method>Install Automatically</deployment_method>
<redeploy_on_update>Newly Assigned</redeploy_on_update>
<redeploy_days_before_certificate_expires>0</redeploy_days_before_certificate_expires>
<payloads><?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1"><dict><key>PayloadUUID</key><string>b5b6e118-b73c-4aab-bdfd-0f281a1e5fe6</string><key>PayloadType</key><string>Configuration</string><key>PayloadOrganization</key><string>SAMF</string><key>PayloadIdentifier</key><string>b5b6e118-b73c-4aab-bdfd-0f281a1e5fe6</string><key>PayloadDisplayName</key><string>WiFi</string><key>PayloadDescription</key><string/><key>PayloadVersion</key><integer>1</integer><key>PayloadEnabled</key><true/><key>PayloadRemovalDisallowed</key><true/><key>PayloadContent</key><array><dict><key>PayloadUUID</key><string>3726EF50-305E-4670-9171-5391FB115E8E</string><key>PayloadType</key><string>com.apple.wifi.managed</string><key>PayloadOrganization</key><string>SAMF</string><key>PayloadIdentifier</key><string>3726EF50-305E-4670-9171-5391FB115E8E</string><key>PayloadDisplayName</key><string>WiFi (JAMF Software Test Network)</string><key>PayloadDescription</key><string/><key>PayloadVersion</key><integer>1</integer><key>PayloadEnabled</key><true/><key>HIDDEN_NETWORK</key><false/><key>Password</key><string>samplePass</string><key>EncryptionType</key><string>WPA</string><key>AutoJoin</key><true/><key>CaptiveBypass</key><false/><key>ProxyType</key><string>None</string><key>SSID_STR</key><string>JAMF Software Test Network</string></dict></array></dict></plist></payloads>
</general>
<scope>
<all_mobile_devices>false</all_mobile_devices>
<all_jss_users>false</all_jss_users>
</scope>
<self_service>
<self_service_description>null</self_service_description>
<security>
<removal_disallowed>Never</removal_disallowed>
</security>
<self_service_icon/>
<feature_on_main_page>false</feature_on_main_page>
<self_service_categories/>
</self_service>
</configuration_profile>'
Posted on 07-23-2019 09:20 AM
Opss sorry I forgot to to update.
You are right we were sending the payloads node in plain (without escaping it).
After fixing it worked (and after adding the site it applies to)
Posted on 09-09-2021 06:51 PM
您好!請教一下
我有嘗試使用此指令
curl -k -v -u admin:1234 -T /path/temp/123.xml -X POST https://jamf.cloud.com/JSSResource/mobiledeviceconfigurationprofiles/id/33
但看起來沒有作用,請問您的使用方式可以分享一下嗎?感謝