Web API Enhancements -Dynamics 365

Hey Techies,

I was going through new What’s new for Developers    and found some thing useful for the developers who uses Web API.

We may need to retrieve entity as soon as you created/updated.

To do this we had to do two operations before

  • Create/Update
  • Retrieve

with this new update we can do the both in one request by specifying header like below

Prefer: return=representation

the above header will retrieve the details of the record which is created/updated.

Request

 POST [Organization URI]/api/data/v8.2/accounts?$select=name,description,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": "Test",     
    "description": "This is a test record",
    "accountcategorycode": 1 
}

Response

HTTP/1.1 201 Created
Content-Type: application/json; odata.metadata=minimal
Preference-Applied: return=representation
OData-Version: 4.0

{
    "@odata.context": "[Organization URI]/api/data/v8.2/$metadata#accounts/$entity",
    "@odata.etag": "W/\"536530\"",
    "accountid": "d6f193fc-ce85-e611-80d8-00155d2a68de",
    "accountcategorycode": 1,
    "description": "This is a test record",
    "name": "Test"    
}

 

Hope this will help somebody 🙂

Thank you,

Sreeni

Published by Sreeni Pavalla

Working as a Assistant Technical Manager in Positive Edge Technologies. Having over 11 years of extensive hands-on experience in MS Dynamics CRM 4.0, 2011, 2013, 2015, 2016, Dynamics 365 with over 5 years of experience in CRM Online. You can visit my blog here https://sreenipavalla.me/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: