Dynamics 365 API: Create Related Entities in One Operation Error 404 Bad Request

Recently we had a project that utilized the Dynamics 365 API extensively. The best practice of course in this types of scenario is to have as few API requests as possible.

In creating Dynamics 365 records using the API, you can create the record and the related entities in one operation. See: https://msdn.microsoft.com/en-us/library/gg328090.aspx

Trying this however, we always got an Error 400 (Bad Request) from the API.

 

The reason is… we were using the field’s Logical Name when we should be using the Schema Name.

In the image below, there is a Main Record and a Related Record.

The Main Record has a lookup to the Related Record named Message Type ID

  • Logical Name: smsmt_messagetypeid
  • Schema Name: smsmt_MessageTypeId

 

API CALL.PNG

When the lookup field has been changed to schema name, it returned a success

API CALL2.PNG

 

 

TIP: When creating the Dynamics 365 attributes, make your Schema Name all lowercase.

It will save you a lot of trouble.

SampleField.PNG

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s