Announcements
HI
I have successfully connected D365 WebAPI with Postman but every time I GET or POST something , I need to regenerate access token and use that new token . Is there any way I use only one token and not need to recreate it ?
Second question is , How I can use WebAPI on my website to send data from my website(json , php) to D365 ? As I need to recreate access token every time , I can not use access token . Is there anyway I can use only API key or clientid and client secrete key for connection ?
Thanks
Hemisha
Good to hear that
HI
I have solved the issues . It was silly php syntax issues .
'Authorization: Bearer '.$accessToken instead of 'Authorization: Bearer $accessToken'
Thank you all for help .
Thanks
Hemisha
Hi Hemisha,
Please take a look at these git repo. They are also using similar kind of integration: github.com/.../php-crm-toolkit
github.com/.../dynamics-sdk-php
You can find the code in src folder.
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
Hi,
Check if you have enabled security group for your Environment, if yes then make sure your user is part of this security group
Please check if the application user has the correct rights.
docs.metallic.io/.../136228_register_dynamics_365_application_with_azure.html
Please check point 14 in this: www.c-sharpcorner.com/.../
Hi
I am the admin of the organization but still getting same error .
Check if the user have appropriate roles in Dynamics 365 environment?
Please check if the user has appropriate rights. Also you have an application user in D365
Hi
Thank you for your code . Now I am getting bellow error
: {"error":{"code":"0x80072560","message":"The user is not a member of the organization."}}
I did check all setting . User is the member of organization. Dont know what else I need to set .
Thanks
Hemisha
André Arnaud de Cal...
293,296
Super User 2025 Season 1
Martin Dráb
232,093
Most Valuable Professional
nmaenpaa
101,156
Moderator