2013-03-05 52 views
0

我正嘗試使用Windows Azure Graph for Office365的其餘API創建組。我的XML有效載荷傳遞給URL https://graph.windows.net/49aa83c813-59c999-4e29-a753-25fd8caebe93/GroupWindows Azure圖形AD使用Rest API創建組

淨荷其中我傳遞是

<?xml version="1.0" encoding="UTF-8" standalone="no"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><content type="application/xml"><m:properties><d:DisplayName>testingGroup</d:DisplayName><d:Description>Test group</d:Description><d:MailEnabled>true</d:MailEnabled><d:DirSyncEnabled>false</d:DirSyncEnabled><d:SecurityEnabled>false</d:SecurityEnabled><d:ObjectType>Group</d:ObjectType><d:MailNickname>firstGroup</d:MailNickname><d:Mail>[email protected]</d:Mail></m:properties></content></entry> 

我接收400錯誤作爲響應。任何人都可以告訴我正確的XML payLoad通過。

回答

1

首先,您的請求URI不正確。有關如何用圖形API的0.8版本的一組,應該是這種格式:

https://graph.windows.net/yourtenantdomainname.com/Group

你的租客也可能是* .onmicrosoft.com地址。其他一些東西:該服務目前不支持設置DirSyncEnabled或Mail屬性。它們都是隻讀的。目前,您需要將MailEnabled設置爲false,並將SecurityEnabled設置爲true。

要使用0.8版本的一組,這是你的要求將是什麼樣子:

POST https://graph.windows.net/yourtenantname.com/Groups HTTP/1.1 
Authorization: Bearer eyJ0eXAiOiJK...vYiFqfkg 
Host: graph.windows.net 
Content-Type: application/atom+xml 
x-ms-dirapi-data-contract-version: 0.8 
Content-Length: 725 

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> 
    <content type="application/xml"> 
    <m:properties> 
     <d:DisplayName>testingGroup</d:DisplayName> 
     <d:Description>Test group</d:Description> 
     <d:MailEnabled>false</d:MailEnabled> 
     <d:ObjectType>Group</d:ObjectType> 
     <d:SecurityEnabled>true</d:SecurityEnabled> 
     <d:MailNickname>firstGroup</d:MailNickname> 
    </m:properties> 
    </content> 
</entry> 

注意,圖形API 0.9於近日發佈:http://blogs.msdn.com/b/aadgraphteam/archive/2013/03/03/0-9-version-of-azure-active-directory-graph-now-available.aspx

如果你想創建一個使用最新版本的API,這就是您的請求如何使用XML作爲有效負載(請注意URI中的camelCase屬性和「組」):

POST https://graph.windows.net/yourtenantname.com/groups?api-version=0.9 HTTP/1.1 
Authorization: Bearer eyJ0eXAi...YiFqfkg 
Host: graph.windows.net 
Content-Type: application/atom+xml 
Content-Length: 627 

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> 
    <content type="application/xml"> 
    <m:properties> 
     <d:displayName>testingGroup</d:displayName> 
     <d:description>Test group</d:description> 
     <d:mailEnabled>false</d:mailEnabled> 
     <d:objectType>Group</d:objectType> 
     <d:securityEnabled>true</d:securityEnabled> 
     <d:mailNickname>firstGroup</d:mailNickname> 
    </m:properties> 
    </content> 
</entry> 

最後只是爲了好玩,如果你想使用新支持的最小JSON,有效載荷將如下所示:

{ 
    "displayName": "testingGroup", 
    "description": "Test group", 
    "mailNickname": "firstGroup", 
    "mailEnabled": false, 
    "securityEnabled": true 
} 
相關問題