RE: How to update record in CRM Dynamics 365 using Web API?
To retrieve data from an entity you are updating you can compose your PATCH
request so that data from the created record will be returned with a status of 200 (OK). To get this result, you must use the return=representation
preference in the request headers.
To control which properties are returned, append the $select
query option to the URL to the entity set. The $expand
query option will be ignored if used.
This example updates an account entity and returns the requested data in the response.
Request
PATCH [Organization URI]/api/data/v9.0/accounts(00000000-0000-0000-0000-000000000001)?$select=name,creditonhold,address1_latitude,description,revenue,accountcategorycode,createdon HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json
Content-Type: application/json; charset=utf-8
Prefer: return=representation
{"name":"Updated Sample Account"}
Response
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
Preference-Applied: return=representation
OData-Version: 4.0
{
"@odata.context": "[Organization URI]/api/data/v9.0/$metadata#accounts/$entity",
"@odata.etag": "W/\"536537\"",
"accountid": "00000000-0000-0000-0000-000000000001",
"accountcategorycode": 1,
"description": "This is the description of the sample account",
"address1_latitude": 47.63958,
"creditonhold": false,
"name": "Updated Sample Account",
"createdon": "2016-09-28T23:14:00Z",
"revenue": 5000000.0000,
"_transactioncurrencyid_value": "048dddaa-6f7f-e611-80d3-00155db5e0b6"
}
I hope this helps!
Regards,
Lewis
Developer
apps4rent | o365cloudexperts