Hi,
I go with this link for update the entities with API,
the sample works well, with account changed,
however , if I apply the same to contacts, like
change the uri to
PATCH [Organization URI]/api/data/v9.1/contacts(00000000-0000-0000-0000-000000000001) HTTP/1.1
and content
{ "Firstname": "Updated first name " }
I get error
Hi gordon,
Please let me know whether you had other problem.
If you had found any answer helped, please kindly mark as verified, it would be greatly appreciated.
Regards,
Clofly
Thanks Clofly,
It works by change the Firstname to firstname,
I am using the postman .
Hi Gordon,
Firstname should be firstname, please pay attention to letter case of fields.
A full code for update a contact:
var entity = {
"firstname": "Mike 1",
"lastname": "Johnson"
};
var req = new XMLHttpRequest();
req.open("PATCH", Xrm.Page.context.getClientUrl() "/api/data/v9.1/contacts(xxxx)", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
alert("ok");
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
In addition, you could automatically create create/update with Web API by CRM Rest Builder.
It supports for all CRUD operations.
https://github.com/jlattimer/CRMRESTBuilder
Regards,
Clofly
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156