0

I'm trying to create a group using the rest API of windows azure Graph for Office365. I'm pass the xml payload to the url https://graph.windows.net/49aa83c813-59c999-4e29-a753-25fd8caebe93/Group

The payLoad which I'm passing is

<?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>

I receive a 400 Error as a response. Will anyone be able to tell me the correct XML payLoad to pass.

1 Answer 1

1

First, your request URI is incorrect. For creating a group using version 0.8 of the Graph API, it should be in this format:

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

Your tenant might also be an *.onmicrosoft.com address. A couple other things: the service currently doesn't support setting the DirSyncEnabled or Mail properties. They are both read-only. And currently you need to have MailEnabled set to false and SecurityEnabled set to true.

To create a group using 0.8 version, this is what your request will look like:

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>

Note that 0.9 of the Graph API was released recently: http://blogs.msdn.com/b/aadgraphteam/archive/2013/03/03/0-9-version-of-azure-active-directory-graph-now-available.aspx

If you want to create a group using the latest version of the API, this is how your request would look using XML as the payload (note the camelCase properties and "group" in the URI):

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>

And finally just for fun, if you want to use the new supported minimal JSON the payload would look like this:

{
    "displayName": "testingGroup",
    "description": "Test group",
    "mailNickname": "firstGroup",
    "mailEnabled": false,
    "securityEnabled": true
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.