JSS REST API更新配置文件返回Http 409(冲突)

时间:2015-09-14 14:27:39

标签: c# .net http

我目前正在使用JSS Rest Api更新移动设备配置 轮廓。

为此,我们采取以下步骤:

  1. 阅读Mobiledeviceconfigurationprofile(XML格式)。
  2. 修改该配置文件(将移动设备设备添加到 排除/移动设备范围)。
  3. 使用该更新的配置文件作为PUT请求的正文 更新个人资料。
  4. 执行这些操作后,我收到了返回的Http 409状态代码: JSS Documentation Description Error 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>
    

1 个答案:

答案 0 :(得分:0)

问题是您只应上传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>