Unable to create a new mobiledeviceconfigurationprofiles

calarcon
New Contributor II

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

3 REPLIES 3

Tangentism
Contributor II

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>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1"&gt;&lt;dict&gt;&lt;key&gt;PayloadUUID&lt;/key&gt;&lt;string&gt;b5b6e118-b73c-4aab-bdfd-0f281a1e5fe6&lt;/string&gt;&lt;key&gt;PayloadType&lt;/key&gt;&lt;string&gt;Configuration&lt;/string&gt;&lt;key&gt;PayloadOrganization&lt;/key&gt;&lt;string&gt;SAMF&lt;/string&gt;&lt;key&gt;PayloadIdentifier&lt;/key&gt;&lt;string&gt;b5b6e118-b73c-4aab-bdfd-0f281a1e5fe6&lt;/string&gt;&lt;key&gt;PayloadDisplayName&lt;/key&gt;&lt;string&gt;WiFi&lt;/string&gt;&lt;key&gt;PayloadDescription&lt;/key&gt;&lt;string/&gt;&lt;key&gt;PayloadVersion&lt;/key&gt;&lt;integer&gt;1&lt;/integer&gt;&lt;key&gt;PayloadEnabled&lt;/key&gt;&lt;true/&gt;&lt;key&gt;PayloadRemovalDisallowed&lt;/key&gt;&lt;true/&gt;&lt;key&gt;PayloadContent&lt;/key&gt;&lt;array&gt;&lt;dict&gt;&lt;key&gt;PayloadUUID&lt;/key&gt;&lt;string&gt;3726EF50-305E-4670-9171-5391FB115E8E&lt;/string&gt;&lt;key&gt;PayloadType&lt;/key&gt;&lt;string&gt;com.apple.wifi.managed&lt;/string&gt;&lt;key&gt;PayloadOrganization&lt;/key&gt;&lt;string&gt;SAMF&lt;/string&gt;&lt;key&gt;PayloadIdentifier&lt;/key&gt;&lt;string&gt;3726EF50-305E-4670-9171-5391FB115E8E&lt;/string&gt;&lt;key&gt;PayloadDisplayName&lt;/key&gt;&lt;string&gt;WiFi (JAMF Software Test Network)&lt;/string&gt;&lt;key&gt;PayloadDescription&lt;/key&gt;&lt;string/&gt;&lt;key&gt;PayloadVersion&lt;/key&gt;&lt;integer&gt;1&lt;/integer&gt;&lt;key&gt;PayloadEnabled&lt;/key&gt;&lt;true/&gt;&lt;key&gt;HIDDEN_NETWORK&lt;/key&gt;&lt;false/&gt;&lt;key&gt;Password&lt;/key&gt;&lt;string&gt;samplePass&lt;/string&gt;&lt;key&gt;EncryptionType&lt;/key&gt;&lt;string&gt;WPA&lt;/string&gt;&lt;key&gt;AutoJoin&lt;/key&gt;&lt;true/&gt;&lt;key&gt;CaptiveBypass&lt;/key&gt;&lt;false/&gt;&lt;key&gt;ProxyType&lt;/key&gt;&lt;string&gt;None&lt;/string&gt;&lt;key&gt;SSID_STR&lt;/key&gt;&lt;string&gt;JAMF Software Test Network&lt;/string&gt;&lt;/dict&gt;&lt;/array&gt;&lt;/dict&gt;&lt;/plist&gt;</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>'

calarcon
New Contributor II

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)

peitang
New Contributor II

@calarcon 

您好!請教一下
我有嘗試使用此指令

curl -k -v -u admin:1234 -T /path/temp/123.xml -X POST https://jamf.cloud.com/JSSResource/mobiledeviceconfigurationprofiles/id/33

但看起來沒有作用,請問您的使用方式可以分享一下嗎?感謝