SharePoint List Item Update - Concurrency Using REST API - rest

I'm using REST API for updating the SharePoint list item (Counter). In my code on form load I'm fetching the count from list and increment to 1 & on submit button click I'm updating the value of count. Till here I have achieved.
Problem arises , If two users submit the form at the same time, then counter value is incremented by 1 instead to 2 in the list.
Checked with etags . But I found that during post if etag doesn't match with get request etag then error will be thrown.
Is there way to achieve this functionality using REST API also incrementing the counter properly , if more than 3-4 users submit the form ?

SharePoint doesn't expose a transaction manager such that you could group multiple rest operations in one atomic transaction.

Related

Azure Data Factory: Pagination in Data Flow with Rest API Source

I have a API source in an ADF DataFlow task. The API source gives me the current page and the toatl number of pages in the body of the response. I want to use that information to paginate through my API source. I'm able to paginate through it just fine outside of a DataFlow activity using the range function. The issue is that the Rest transformation in a DataFlow activity does not support the range function. I've been trying to use the AbsoluteUrl function plus an expression to do add one to the current page returned by the body but either pagination does not accept expressions or I cannot figure out the syntax
I have a url like this:
BaseURL/fabricationcodes?facets=relatedArticles:Not%20Empty&page={PageNumber}.
In this example my rest linked service URL has everything I need minus the &page=pageNumber. So I'm trying to add that part with the key/value pair function of AbsoluteUrl. The Key being &page= and the value should be currentPage +1. My desire is for it to get the first page, page 0 and then add +1 to that to formulate the next pages url. the end condition being when body.totalPages == body.currentPage
I've tried a bunch of different expression formaulations but none seem to work and debugging in a Data flow is tough b/c the logging and error messaging is poor
What I have right now.
As data flow don't support Range option or you cannot use dynamic expression to get page from API response.
To work around the issue, you can use Data Flow activity within ForEach loop using range function in dynamic expression.
First take a web activity and pass the URL of the Rest API as below Ito get the total no of Pages from API response
then take a for each activity to iterate on API like pagination give the Dynamic expression as #range(1,activity('Web1').output.total_pages)
I will iterate the API till the respective range in sequential manner.
create parameter with type string in source DataSource.
give that parameter as dynamic value in relative URL.
after this gave parameter value as ?page=#{item()} to give the no coming from range to the page.
OUTPUT:

Jama API - GET item with tag at the same time

I need to fetch items from JAMA API, and I do not get the Tag value with the data.
I tried to call GET/{item}/{id} API and then I also need to execute GET/{tags}/{id}/{item} to discover item tag, which takes too much time for multiple items.
Is there any more efficient way to get all data in one API call?
There is the /items/{id}/tags endpoint: https://rest.jamasoftware.com/#operation_getTagsOnItem

asynchronous bulk data validations service - GET or POST?

Here is a different scenario for GET or POST confusion. I am working on a web application built with spring-boot microservice architecture where there is a need of validate and update some bulk data from excel sheet.
There can be 500-1000 records in excel sheet with 6 different columns for bulk processing. Once UI submits the excel sheet to server from then the total process is asynchronous. There are microservice to microservice calls which I am getting confused to have GET or POST.
Here is a problem: I have 4 microservices (let's say orchestra-service,A-service,B-service and C-service).
OrchestraService creates a DTO list from excel sheet which will be used in further calls. Orchestra calls 'A'. 'A' validates the data with DB and marks success and failure records in DTO list object and returns the list back to orchestra. Again orchestra calls 'B', it does the similar job like 'A' and returns back to orchestra.
Now orchestra calls 'C' which will update success records into database, updates the file status on database and also creates a new resultant excel sheet with error messages per row which will be emailed to the user later(small report kind of thing).
In above microservice to microservice calls only C is updating database and creating resource on server. All above calls I used POST method because I need the request body to pass my input list to all services.
According to HTTP Standards am I doing right?
https://www.rfc-editor.org/rfc/rfc7231#section-4.3.3
Providing a block of data, such as the fields entered into an HTML form, to a data-handling process it should be a POST call.
Please advice me whether:
I should use POST for only 'C' and GET for others or
It should be POST for all as other process involves in data filtering process.
NOTE: service A,B, and C not all services uses all the columns of excel but some of them in combinations. One column having 18 characters long data so I think it can be a problem with GET header limit for bulk operation.
Http Protocol
There is no actual violation on passing information on GET and if that request doesn't mutate between identical requests, then it's fine.
Microservice wise
Now for clarification, are Service A and Service B actually needed ?
Aren't they the same Domain as Service C, and can reside inside of him ?
It's more then good practice to have a Microservice validate its own domain and return a collection of success and failure with the relevant messages.
I had the similar question few years back and here is the possible solution for the first part of your question.
As mentioned by #Oreal Eraki in his answer, I would also question whether you need services A and B. If its just validation and data transformation it can be done in the same domain where the data is actually stored.

How do i get the list of all the leads in Marketo

I want to get all leads in Marketo using their Rest Apis. Is there a way to do this? I have already tried the getLeadChanges api, however that only returns leads with changed fields.
Leads in Marketo are assigned lead ids in sequential order starting with 1. Using the Get Multiple Leads by Filter Type REST API endpoint, you can query 300 leads by lead id with each call.
You will have to specify id as the filterType and the lead ids as the filterValues with each call to this endpoint. To get all leads, you would iterate through the total number of leads 300 at a time.
The first API call would be (replace ... with all the values in between):
/rest/v1/leads.json?filterType=Id&filterValues=1,2,3,...,298,299,300
The second API call, and each subsequent API call would follow the same pattern:
/rest/v1/leads.json?filterType=Id&filterValues=301,302,303,...,598,599,600
By Marketo REST API you can request only static lists, and the "All leads" is dynamic.
Easyest way will be:
Create static list
Add all existing leads to this list
Create a Marketo campaign to add every new lead to this Static list.
then just query leads in this list. e.g.: https://%yourSubdomain%.mktorest.com/rest/v1/lists/%listId%/leads.json
Hope it will help.

how to query a set of random entries tastypie

I have events module .my user favroite some of random events from listing . i will store them in favroite table of my database
id module
1 events
5 events
9 events
2 business
now , my question how can i make a query to fetch 1,5,9 at single request for event ? is there any way to request it
Yes, you can filter by id to get multiple events in one request, look at the selected answer to this question to learn how to do that. Should work out of the box.