I have set the MS Azure API permissions of contacts.read.write but when executing the following code I get this message:
Uncaught GuzzleHttp\Exception\ClientException: Client error:
POST https://graph.microsoft.com/beta/contacts
resulted in a400 Bad Request
response: { "error": { "code": "Request_BadRequest", "message": "A value without a type name was found and no expecte (truncated...) in C:\Program Files\Ampps\www\weedo\weedo2\content\libraries\MicrosoftGraph\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113
My post code:
$graph = new Graph();
$graph
->setBaseUrl("https://graph.microsoft.com/")
->setApiVersion("beta")
->setAccessToken($this->accessToken);
$data = array(
"GivenName" => "Test",
"Surname" => "account",
"EmailAddresses" => array(
array(
"Address" => "testaccount@mail.com",
"Name" => "Mail Name"
)
)
);
$user = $graph->createRequest("POST", "/contacts")
->addHeaders(array("Content-Type" => "application/json"))
->setReturnType(Model\User::class)
->attachBody($data)
->setTimeout("1000")
->execute();
I believe I followed these pages correctly, but the examples are not all given for PHP so I'm not sure where to go from here: https://github.com/microsoftgraph/msgraph-sdk-php https://learn.microsoft.com/en-us/graph/api/user-post-contacts?view=graph-rest-1.0&tabs=http
I also wrapped the $data parameter in a json_encode just for testing, but no luck. Where to go? What to do?
EDIT: So as seems i was confused with organizational contacts (which are obtained by /contacts) and personal contacts (which are obtained by /me/contacts). Now it is not (yet) supported to create organizational contacts, which i find rediculous but for some reason i'm not allowed to create contacts on application based either. any thoughts / ideas on this?