Set CRM Lookup Values with WebAPI

徘徊边缘 提交于 2019-12-06 03:56:23

Case matters with the WebAPI. Make sure your col_contactid is the schema name, not the logical name. For example, the logical name of your attribute is col_contactid (logical names are always lowercase), but schema names often times have upper case letters. Yours might be col_ContactId for example, in which case you would want to use col_ContactId@odata.bind.

The easiest way to find the schema name of your attribute is by going to CRM -> Settings -> Solutions -> your solution -> Entites (on the left) -> Advisors -> Fields. In that grid you'll see a column for schema name.

RichW

I got it to work. The fields really have to be unique as it is case sensitive. Comments here and also this blog, really helped.

http://inogic.com/blog/2016/02/set-values-of-all-data-types-using-web-api-in-dynamics-crm/

Step 1 : Goto Cutomization  Developer Resource.

Step 2 : Click to “Download Odata Metadata” link and Download the same.

Step 3 : Once Download, open it and find out name of lookup attribute ( i.e. new_qualifiedleadid) and check its casing.

Step 4 : Verify it with the value which you are setting in the code it should be same.

While my column was col_contactid, CRM renames the Navigational Column to be what was above col_ContactId.

I also used Postman(google chrome) plugin and added the following Header to my Post.

webClient.Headers.Add("Prefer", "odata.include-annotations=*");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!