Dynamics Web API BATCH POST vs PATCH (remove navigation property value) - dynamics-crm-2011

I am attempting to Disassociate a reference 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",
"lookup1#odata.bind": null,
"lookup2#odata.bind": null,
"lookup3#odata.bind": 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!

Read your question while searching for related CRM WEB API challenges.
The response may be a bit overdue but here's what I think applies to your case:
POST, GET, PUT, PATCH, and DELETE are HTTP request types.
When using PATCH on MS CRM you can only edit a single record.
When you want to perform multiple operations at once you use a POST request to post a whole batch of different requests. This can include multiple PATCH requests.
How to POST a batch is described quite okay here:
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/execute-batch-operations-using-web-api

Related

How to store Body data in post request through jmeter

I am new to jmeter, I am using jmeter to test e-commerce website.
I have manage to script one scenario, which is to add a product in basket and test the response time.
Now, I have observed that when i click Add button on UI, their are two requests which are getting POSTED.
for eg: stocks are updated.
As of now, I have copied the BODY from stock and pasted in jmeter sampler, but in future i may change the Sales order and update scenario, hence i want to store this Body data(Stock request which is updated) of this request dynamically, as it will change corresponding to sales order number im providing.
The problem is I am not able to store the BODY data dynamically(Only if i change the sales order here).
I know i can use pre processor in this matter, but could anyone help me with the code to get the BODY data from the request and store dynamically before sending the sample.
Basically I need a solution where I am just updating my sales order number and rest of the things will be taken care dynamically, in my case the POSTING of Body data for updating the STOCK.
Thank you in advance!
See basically, you're talking about Correlation. As I can understand from your concern. You need the data for the product added to the cart. Which needs data from prev request. This can be easily managed by generating two requests. Extracting from first and using that info for the second one. This will not involve any hardcoding and will work for you in an efficient manner.
Something like:
vars.put('bodyData', sampler.getQueryString())
should do the trick for you, if you put this code into a JSR223 PreProcessor and add this PreProcessor as a child of the HTTP Request sampler which body you need to store - you will be able to access the request body as ${bodyData} later on where required
In the above example:
vars - stands for JMeterVariables class instance
sampler - is for HTTPSamplerProxy
More information: Top 8 JMeter Java Classes You Should Be Using with Groovy

How can I paginate Pagerduty REST API results when requesting incident lists?

I'm building an application which pulls down incident listings for my org via Pagerduty's REST API.
The GET /incidents endpoint does respond with more, offset, and other keys that are indicative of pagination being supported, and it does make intuitive sense on this endpoint, but I haven't been able to actually paginate these results:
Passing offset or limit as a query param returns a 403
Passing these in various forms in request headers just gets ignored entirely
Is there a way to paginate these results at all?
it might help to include the code you're using to make the request, or a curl request from the command line. Including pagination parameters shouldn't lead to a 403, so I'm thinking something else might be missing.
You should be able to paginate the lists using GET parameters, e.g
https://api.pagerduty.com/incidents?limit=20&offset=100
limit has a maximum value of 100, and limit + offset together must be less than 10,000. That might be why you were getting an error?
See here for additional details on the pagination parameters
Yes, it's possible to paginate the results.
After invoking the API method for the first time, you need to check the more response field value. If true, then you can call the API method again with an updated offset.
offset is related to the total results, and not the total pages.
The 403 error code response you're getting is most likely related to the user permissions and not with paginating results.

REST API - execute multiple actions

Currently trying to work out how to use REST API to execute an action.
I added the ReverseInvoice action from Bills screen on my endpoints. And seems execute fine. Unfortunately, executing an action does not return a result e.g. 204 No Content. I'd wish to extract the RefNbr of the Debit Adj. raised.
Second problem is how do you stack actions or call series of actions ? The raised Debit Adj is not Released. So it seems ReverseInvoice & Release need to be executed at the same time. Plus, I also need them to be allocated against each other automatically.
I've got a feeling the REST API is not the way to go with this one.
Cheers and thanks for responses.
Unfortunately, you're correct on both points: Acumatica's Contract-based API (both SOAP and REST flavors) doesn't allow you to get the entity that is a result of an action (you can only get the status of action invocation), and if you want to chain a sequence of action you'll have to do that manually from the client (call one action, check for the status, call the second one, check, raise, rinse, repeat). Or you can write a customization with a custom action that call two actions in sequence, and call that from the API.

SeriesMaster not being returned when getting the CalendarView using the Office 365 API

The documentation (https://msdn.microsoft.com/en-us/office/office365/howto/sync-calendar-view) for getting a calendarview implies that the SeriesMaster event will be returned in the result, along with the individual occurrences and exceptions.
The documentation states (and shows by example):
Here's the information you need to know about how recurring events are handled for calendar view synchronization.
The service performs meeting expansion and sends the series master event and all of the event instances within the time window.
The series master event contains the recurrence pattern and the time window for the series.
The event instances contain their start and end time information as well as information about event occurrence exception.
However in actually using this endpoint, we're only receiving back the Occurrences/Exceptions and not the recurrence "master". The Occurences are full models, unlike slimmer models containing only the start/end like the documentation states.
It's important for us to be able to get sync SeriesMaster events along with the exceptions for the series (as is possible with GCal singleEvents=false) such that we can store this information and perform recurrence expansion on the client-side.
What am I doing wrong here?
Request (decoded for readability):
GET https://outlook.office365.com/api/v1.0/Users(...)/calendarview?$sort=startDateTime desc&$top=100&startDateTime=2016-01-01T22:12:34+0000&endDateTime=2016-03-10T23:12:34+0000
There is a similar issue when we try to get the CalendarView in EWS.
The Outlook calendar sync REST API works well as the description for me. Did the API works for you when you remove the $top query parameters?
Because the Outlook calendar sync REST API doesn't support $filter, $count, $select, $skip, $top, and $search query parameters.
Here is the link for the sync API for your reference:
https://msdn.microsoft.com/office/office365/api/calendar-rest-operations#Syncevents
Here is the response from calendar sync for your reference:

Combine multiple http request or not?

Some web design questions.
Combine POST with GET?
When user clicks a button, I need to send one POST to submit a form, then need to GET a json object to replace some DOM fields. Should I combine them into one request so save one round trip time?
Multiple GET json request?
When user clicks a button, I need to GET 3 or 4 json object. Should I send 3 or 4 GET request, or just one and combine the json into one large json at back-end?
So basically, I'm not sure which is heavier: round trip time VS a little complexed back-end and front-end logic.
Any comment is welcome!
if i understood your question right...you have a dependency on your get requests...that is to say the second get depends on the first...if that is the case, obviously you need to take consecutive get operations...however, if that is not the case that is if you know the order of get request and the response won't be affected by local conditions...then i suggest you do post/get operations on server side...trigger the first one an let the server handle the rest and get the result...
of course you would not want users do multiple get requests for one simple operation...

Resources