How to allow other users to create contacts in my account using API.

marcell 1 Reputation point
2021-07-30T17:20:23.23+00:00

Basically our company has a CRM, we want to be able to create contacts for a specific outlook account using the Outlook API.

How can I achieve that? I've read there are "delegated permissions" but I'm not too sure how tu use them. Thank you so much!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,445 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 40,311 Reputation points
    2021-08-02T08:19:37.763+00:00

    You can use the application principal to create contacts in your account. Please note that you cannot use delegated permissions, because delegated permissions are limited to creating contacts yourself. According to your question, you should use application permissions and then call the /users/{your user id} endpoint to create contacts for your account (note that this process will not involve users, this is your application principal completed). In addition, since the Outlook API has been deprecated, I recommend you to use the latest MS graph api.

    Therefore, you need to grant the Contacts.ReadWrite application permission to your application, then use the client credential flow to obtain the token, and then use the token to call the /contacts endpoint.

    119785-230.png

       POST https://graph.microsoft.com/v1.0/users/{user id}/contacts  
       Content-type: application/json  
         
       {  
         "givenName": "Pavel",  
         "surname": "Bansky",  
         "emailAddresses": [  
           {  
             "address": "pavelb@fabrikam.onmicrosoft.com",  
             "name": "Pavel Bansky"  
           }  
         ],  
         "businessPhones": [  
           "+1 732 555 0102"  
         ]  
       }  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments