Hi
I have created new user and then it was working fine. But but when I try to create account using bellow code , I am getting error . Same thing working fine in postman .
I am getting
{"error":{"code":"0x80048d19","message":"Error identified in Payload provided by the user for Entity :'accounts'
my code :
$curl = curl_init();
$clientId = "xxxxxxxx";
$clientSecret = "xxxxxxx";
$tenantId = "xxxxxxx";
// Build the body for the token request
$body = [
'grant_type' => 'client_credentials',
'client_id' => $clientId,
'client_secret' => $clientSecret,
'resource' => 'https://xxxx.dynamics.com'
];
$url = "">login.microsoftonline.com/.../token";
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($body));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$response = json_decode($response);
$accessToken = $response->access_token;
curl_close($curl);
$headers = [
"Authorization: Bearer ".$accessToken,
"OData-MaxVersion: 4.0",
"OData-Version: 4.0",
"Accept: application/json",
"Content-Type: application/json; charset=utf-8"
];
$body1 = [
'name' => 'testtest'
];
$url = "">xxxxxx/.../accounts";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($body1));
$response = curl_exec($curl);
curl_close($curl);
Any one suggest me why ?
Thanks
Hemisha