SharePoint batch REST API request creates duplicate items. Is this a known issue? How to overcome this?

Deval 31 Reputation points Microsoft Employee
2023-02-27T07:41:16.8533333+00:00

I am using SharePoint batch rest APIs to create items in a SharePoint online list site.

The use case is this: There are more than 7000 items in source (which is not SPO) and they get updated/added/deleted frequently.

I am fetching these items or data from my source and adding them to one list in an SPO site and then using this data to create Power BI reports.

I am using batch REST APIs and first deleting all items from the list and then adding the new data in a batch of 100 items to the list.

I am using Power Automate with recurrence trigger to refresh the target or to perform above actions 4 times a day at regular intervals.

The issue is sometimes it works fine and creates exact no. of items, but sometimes it creates duplicates of items in all the batches.

I am sure that the duplicates are created by the batch request only because for all the duplicates the created time is exactly same in the SharePoint list. (see the exported data image)

Exported data

I am not sure what could be the issue, as no error is returned from the batch API response.

I am sure that this issue is not with the Power Automate because it is sending exact no of batches in both scenarios when this works fine and when it does not.

Is this a known issue with batch APIs?

What could be the possible solution for this?

Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2023-02-28T01:52:57.93+00:00

    Hi @Deval,

    In my experience, RESTful services with lots of traffic are bound to receive duplicate incoming POST requests unintentionally - e.g. sometimes a user will click 'Signup' and two requests will be sent simultaneously. This should be expected and handled by your backend service.

    This issue could be handled in the backend using unique checks. You can add a GUID column and enforce unique in SharePoint list. When the duplicate request ocurs, the enforce unique will prevent duplicate item create.

    Here is a similar issue with yours, please make a reference

    https://stackoverflow.com/questions/15159274/avoid-duplicate-posts-with-rest


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.