Web API Batch POST vs PATCH

0
28
Forum Post: Change the Filter On option on Opportunity Associated View for Account form


I am attempting to disassociate a contact reference to a single-valued navigation property by setting the value to null.

This works when I call the web api directly: 

PATCH https://mydynamics.crm.dynamics.com/api/data/v9.2/contacts(00000000-0000-0000-0000-000000000000)
{ “firstname”: “John”,
“lastname”:”Doe”,
[email protected]”: null,
[email protected]”: null,
[email protected]”: null
}
//[…other data omitted for brevity…]

So these lookup fields, lookup 1,2, and 3 would be reset to null (The association is removed).

We run a synchronization program that calls these operations in a batch and when this runs — using the same payload — the lookup fields fail to reset (although if I modified firstname or lastname – those fields would update). This is a POST batch call containing just the single PATCH operation in this case but it normally contains multiple operations.
All documentation I can find states that PATCH with multiple operation should be a POST call but it didn’t reset my lookups. 

If I change the POST batch to a PATCH batch…then it works as expected and all fields are updated correctly including the lookups!

Why the difference between BATCH POST vs PATCH?!

  • Is is a bug in the API?
  • Is it because I only had a single operation in the batch? Would it work for multiple requests? (I didnt try).
  • Does using PATCH instead of POST have any negative affect on either a single operation or multiple operations?  Suppose a DELETE operation was also in the batch for something?
    Microsoft says Use a POST request to submit a batch operation that contains multiple requests. A batch request can include GET requests and change sets.”
  • Why is the documentation lacking on this topic?

Any help is appreciated!



Source link

Leave a reply

Please enter your comment!
Please enter your name here