2013-03-05 61 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 
}