【问题标题】:JSS REST API Updating profile returns Http 409 (Conflict)JSS REST API 更新配置文件返回 Http 409(冲突)
【发布时间】:2015-09-14 14:27:38
【问题描述】:

我目前正在使用JSS Rest Api 更新移动设备配置 个人资料。


为了做到这一点,正在采取以下步骤:

  1. 读取移动设备配置文件(XML 格式)。
  2. 修改该配置文件(将 mobiledevicedevice 添加到 排除/移动设备范围)。
  3. 使用更新后的配置文件作为 PUT 请求的主体,当 更新个人资料。

在这些操作之后,我得到一个返回的 Http 409 状态码:

注意:为了便于阅读,下面的代码示例已经过修改。例如,不包括异常处理

示例代码

//Service Declaration
JSSApi.MdmInterfaceClient AppleApi = new JSSApi.MdmInterfaceClient();

//Read the Profile - Scroll down to see response
var XmlProfileResponse = AppleApi.ReadMobileConfigurationProfile(mConfig.Id.ToString(), inXML:true);

XElement XmlDocX = XElement.Parse(XmlProfileResponse);
XmlDocX.Element("scope").Element("exclusions").Element("mobile_devices")
                .Add(new XElement("mobile_device", 
                new XElement("id", "#MyMobileDeviceID#"), 
                new XElement("name", "#MyMobileDeviceName#"), 
                new XElement("udid", "#MyMobileDeviceUDID#")));

AppleApi.UpdateMobileConfigurationProfile(mConfig.Id.ToString(), XmlDocX.ToString());

XmlProfileResponse

<configuration_profile>
  <general>
    <id>1</id>
    <name>NoCamera</name>
    <description/>
    <site>
      <id>-1</id>
      <name>None</name>
    </site>
    <category>
      <id>-1</id>
      <name>No category assigned</name>
    </category>
    <uuid>E49F0270-85A7-440C-A719-D7B98CEC0D7D</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>E49F0270-85A7-440C-A719-D7B98CEC0D7D</string><key>PayloadType</key><string>Configuration</string><key>PayloadOrganization</key><string>Actacom Demo</string><key>PayloadIdentifier</key><string>E49F0270-85A7-440C-A719-D7B98CEC0D7D</string><key>PayloadDisplayName</key><string>NoCamera</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>790126EB-5B0F-4943-B92C-2FDBDE8948E1</string><key>PayloadType</key><string>com.apple.applicationaccess</string><key>PayloadOrganization</key><string>Actacom Demo</string><key>PayloadIdentifier</key><string>790126EB-5B0F-4943-B92C-2FDBDE8948E1</string><key>PayloadDisplayName</key><string>com.apple.applicationaccess</string><key>PayloadDescription</key><string/><key>PayloadVersion</key><integer>1</integer><key>PayloadEnabled</key><true/><key>ratingRegion</key><string>us</string><key>ratingTVShows</key><integer>1000</integer><key>ratingMovies</key><integer>1000</integer><key>ratingApps</key><integer>1000</integer><key>safariAllowJavaScript</key><true/><key>safariAllowAutoFill</key><true/><key>safariForceFraudWarning</key><false/><key>safariAllowPopups</key><true/><key>safariAcceptCookies</key><integer>2</integer><key>allowDiagnosticSubmission</key><true/><key>forceEncryptedBackup</key><false/><key>allowVoiceDialing</key><true/><key>allowVideoConferencing</key><true/><key>allowInAppPurchases</key><true/><key>allowGlobalBackgroundFetchWhenRoaming</key><true/><key>allowSafari</key><true/><key>allowiTunes</key><true/><key>allowYouTube</key><true/><key>allowScreenShot</key><true/><key>allowExplicitContent</key><true/><key>allowCamera</key><false/><key>allowAppInstallation</key><true/><key>allowAppRemoval</key><true/><key>allowAssistant</key><true/><key>allowGameCenter</key><true/><key>allowMultiplayerGaming</key><true/><key>allowAddingGameCenterFriends</key><true/><key>forceITunesStorePasswordEntry</key><false/><key>allowUntrustedTLSPrompt</key><true/><key>allowCloudBackup</key><true/><key>allowCloudDocumentSync</key><true/><key>allowPhotoStream</key><true/><key>allowAssistantWhileLocked</key><true/><key>forceAssistantProfanityFilter</key><false/><key>allowSharedStream</key><true/><key>allowPassbookWhileLocked</key><true/><key>allowUIConfigurationProfileInstallation</key><true/><key>allowBookstore</key><true/><key>allowBookstoreErotica</key><true/><key>allowChat</key><true/><key>allowCloudKeychainSync</key><true/><key>allowAccountModification</key><true/><key>allowFindMyFriendsModification</key><true/><key>allowOpenFromManagedToUnmanaged</key><true/><key>allowOpenFromUnmanagedToManaged</key><true/><key>allowLockScreenControlCenter</key><true/><key>allowLockScreenControlCenter</key><true/><key>allowLockScreenNotificationsView</key><true/><key>allowLockScreenTodayView</key><true/><key>allowAssistantUserGeneratedContent</key><true/><key>allowAirDrop</key><true/><key>allowAppCellularDataModification</key><true/><key>allowFingerprintForUnlock</key><true/><key>allowOTAPKIUpdates</key><true/><key>allowHostPairing</key><true/><key>forceAirPlayOutgoingRequestsPairingPassword</key><false/><key>forceAirPlayIncomingRequestsPairingPassword</key><false/><key>forceLimitAdTracking</key><false/><key>allowManagedAppsCloudSync</key><true/><key>allowEraseContentAndSettings</key><true/><key>allowSpotlightInternetResults</key><true/><key>allowEnablingRestrictions</key><true/><key>allowActivityContinuation</key><true/><key>allowEnterpriseBookBackup</key><true/><key>allowEnterpriseBookMetadataSync</key><true/><key>allowPodcasts</key><true/><key>allowPredictiveKeyboard</key><true/><key>allowAutoCorrection</key><true/><key>allowSpellCheck</key><true/><key>allowDefinitionLookup</key><true/></dict></array></dict></plist></payloads>
  </general>
  <scope>
    <all_mobile_devices>false</all_mobile_devices>
    <mobile_devices/>
    <mobile_device_groups>
      <mobile_device_group>
        <id>5</id>
        <name>DevGroup01</name>
      </mobile_device_group>
    </mobile_device_groups>
    <buildings/>
    <departments/>
    <limitations>
      <users/>
      <user_groups/>
      <network_segments/>
      <ibeacons/>
    </limitations>
    <exclusions>
      <mobile_devices/>
      <mobile_device_groups/>
      <buildings/>
      <departments/>
      <users/>
      <user_groups/>
      <network_segments/>
      <ibeacons/>
    </exclusions>
  </scope>
  <self_service>
    <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>

【问题讨论】:

    标签: c# .net http


    【解决方案1】:

    问题是你应该只上传xml中的更改。
    例如:

    <configuration_profile>
     <scope>
      <exclusions>
       <mobile_devices>
        <mobile_device>
         <id>4</id>
         <name>Alexanders iPad</name>
         <udid>fc7f1d1fe84845bfd8ec07b7ce30a6f98ac</udid>
        </mobile_device>
       </mobile_devices>
      </exclusions>
     </scope>
    </configuration_profile>
    

    【讨论】:

      猜你喜欢
      • 2017-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-13
      相关资源
      最近更新 更多