Web API might be the next big thing for developers, but it needs some serious work to remove some of the time wasting traits it currently has.
I've been trying to use the Web API to update properties in CRM where I couldn't use a traditional C#/SDK wrapper, and have struggled with syntax despite using the JObject helper class. Here are some of the issues developers need to be aware of.
1. table name need to have 's' to make them plural, if they already have 's' then its 'es'. What's wrong with sticking to the published schema name?
2. Updating traditional fields on an entity, you need to use the lowercase version the fields, but if its a lookup to another entity then its the *schema* name. This inconstancy means people following examples online are likely to fall foul of this as no online examples I've seen involve lookup.
3. You can remove a field value using JObject by setting the field to NULL. However, this does not work when its a lookup field that you now no longer need (e.g. many-to-one). It seems that an elaborate disassociate structure is needed that cannot be done within the same update message. What we ended up doing was making a lookup we don't need GUID.Empty and then using the PlugIn to spot the value and substituting it to a NULL EntityReference. This is a fudge and shouldn't be needed, but at least it works.
Does anybody know where there is a resource of documentation with proper real-world examples of all features with or without the JObject support? As this would have helped me. The discrepancies between name and schema name was big time waster as none of the ms examples dealt with lookups.
I guess one thing to remember... If you can't get Web API to dealt what you need efficiently, at least you can pass a message in and pick it up in a plug-in for processing with full sdk support.
I hope this helps other newbies to this technology.
Steve
*This post is locked for comments