我正在尝试使用Windows Azure的windows azure Graph的其余API创建一个组。我将xml有效负载传递给url https://graph.windows.net/49aa83c813-59c999-4e29-a753-25fd8caebe93/Group
我传递的payLoad是
<?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>firstGroup@companyName.us</d:Mail></m:properties></content></entry>
我收到400错误作为回复。是否有人能够告诉我正确的XML payLoad通过。
答案 0 :(得分:1)
首先,您的请求URI不正确。要使用Graph 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>
请注意,最近发布了0.9的Graph API: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属性和“group”):
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
}