davidyack / Xrm.Tools.CRMWebAPI

This is an API helper for working with the Common Data Service (CDS) Web API
MIT License
143 stars 73 forks source link

Polly integration #86

Open rasmuschristensen opened 5 years ago

rasmuschristensen commented 5 years ago

Working with bulk inserts I pretty often run into the request limit of dynamics. I've tried to wrap the calls using Polly and a policy that handles CRMWebAPIException. For some reason this has no effect and I dont see the WaitAndRetry in effect. I'm using Azure Functions running .net Core, and looking into this lib I see a lot of classic HttpClient code. Not sure if this mix might cause some issues.

mohsinonxrm commented 5 years ago

@rasmuschristensen , can you share your code here? I'm actually planning to opening a pull request to this repo with the latest .net core implementation using the httpclient factory and providing the retry policy there.

Also, you have to think about idempotency for requests that are not GET, so any POST/PATCH will need additional handling/custom handling on the implementing application side.

I'm not sure if you're aware of the new API limits (no I'm not talking about the ones from March 2019 https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/api-limits)

I'm talking about new API Limits from August 2019: https://docs.microsoft.com/en-us/power-platform/admin/api-request-limits-allocations

so yes, everyone should be using $batch request (with max of 100 requests) now or ExecuteMultipleRequest (with max 1000 requests), however, if things go wrong with failed requests in those batches, then for idempotency you'll need to do Get OR RetrieveRequest.

Anyway, things are going to get much complicated/complex going forward, that's for sure.

mohsinonxrm commented 4 years ago

@rasmuschristensen , I'll be opening a pull request in a couple of days (already coded, going to test a bit more) and submitting the changes for @davidyack to review and merge.