-1

I would like to ask questions about Office365 CRM, Use this CRM I got access token, but haplessly how to add contacts and get contact details using that access token. when I tried to add contacts into CRM I have been getting error like 401 Http request. And also I didn't know header fields and payload format of a request sent to CRM.

sathish kannan
  • 65
  • 1
  • 2
  • 12

2 Answers2

0

https://msdn.microsoft.com/office/office365/APi/contacts-rest-operations#GetContacts This is the link used to get access code, user mail address. You have got access_token and user mail address for creating contact.

public static function createcontact($access_token, $user_email) {
    $email = array (
            "Address" => "sample.onmicrosoft.com",
            "Name" => "kkkkk" 
    );
    $email_value = json_encode ( $email );
    $getContactsParameters = array (
            "GivenName" => "sample",
            "Surname" => "xxxxxxx",

            "BusinessPhones" => array (
                    "+00000000" 
            ) 
    );

    $data_string = json_encode ( $getContactsParameters );
    $getContactsUrl = self::$outlookApiUrl . "/Me/Contacts?";

    return self::makeApiCall ( $access_token, $user_email, "POST", $getContactsUrl, $data_string );
}
sathish kannan
  • 65
  • 1
  • 2
  • 12
-1

You have to set scope, set url and set body for creating contact

SCOPE: https://outlook.office.com/contacts.readwrite

URL: https://api.office.com/discovery/v2.0/me/

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
sathish kannan
  • 65
  • 1
  • 2
  • 12