Yuliia Lukianenko
Yuliia Lukianenko

Reputation: 1

Microsoft Graph API - Create Contact doesn't work

I am attempting to use the Create Contacts endpoint for Microsoft Graph API (Doc is here: https://learn.microsoft.com/en-us/graph/api/user-post-contacts?view=graph-rest-1.0&tabs=http) to register new contact for my user. I created body as described in API documentation but getting the error below:

{
    "error": {
        "code": "Request_BadRequest",
        "message": "A value without a type name was found and no expected type is available. When the model is specified, each value in the payload must have a type which can be either specified in the payload, explicitly by the caller or implicitly inferred from the parent value.",
        "innerError": {
            "request-id": "daf78520-50e6-444b-97a2-779762b3e6ed",
            "date": "2020-01-23T14:20:18"
        }
    }
}

Requests used: 1. POST https://graph.microsoft.com/v1.0/{{tenant_id}}/contacts; 2. POST https://graph.microsoft.com/v1.0/me/contacts; Request body example:

{
  "givenName": "Yulia",
  "surname": "Lukianenko",
  "emailAddresses": [
    {
      "address": "[email protected]",
      "name": "Yulia Lukianenko"
    }
  ],
  "businessPhones": [
    "+1 732 555 0102"
  ]
}

Did somebody meet such kind of issue? How you resolved it?

Thank you in advance for your help!

Upvotes: 0

Views: 742

Answers (1)

Abhijeet Jadhav
Abhijeet Jadhav

Reputation: 342

POST request is incorrect here. It should be : https://graph.microsoft.com/v1.0/me/contacts

Also you need to make sure "Contacts.ReadWrite" permission is granted to the app registered in AAD.

P.S: I used the same JSON in your example using graphExplorer and contact was created successfully.

Upvotes: 0

Related Questions