How to publish document after SP upload

Hi @UiPath_Community

Have any of you ever tried to publish document after uploading it onto SharePoint using O365 package?

We have this scenario wherein once the file is uploaded, it doesn’t become available for view unless specifically published.

@sonaliaggarwal47

Well there is no activity..but published in graph api is via a parameter in check in..check below api call

you can use O365 Http request

cheers

1 Like

Hi @sonaliaggarwal47

In SharePoint Online (O365), some libraries require check-in or publishing before a document is visible to others, especially if the library has content approval or minor/major versioning enabled.

Using UiPath with the O365 Activities package, you can do this as follows:

  1. Upload the file
  • Use Upload File activity from the O365 SharePoint package.
  1. Check-in the file (if library requires it)
  • Use Check In File activity.
  • Set the check-in type: MinorCheckIn, MajorCheckIn, or OverwriteCheckIn.
  1. Publish the file (if using major/minor versioning)
  • Use Publish File activity from the same package.
  • This will make the document visible to others if the library requires publishing.
  1. Optional: Approve the file (if content approval is enabled)
  • Use Approve File activity.

Sequence example in UiPath:

  • Upload File → Check In File → Publish File → Approve File (if needed)

Hi everyone,

Thanks for your response.

Upon more research, we found that there are 2 ways check-in can be achieved.

  1. Calling check-in endpoint for graph API using http request

  2. Using the check-in property that is available in upload file activity itself. See below

However, both of these approaches didn’t work for us. Upon further digging and discussions with SP team, we learned that as per library settings enabled for this site, explicit check-out will be needed before check-in can be attempted.

So, we had to do follow below approach:

  1. Upload file

  2. Fetch Id of uploaded file and its site Id

  3. Get access token for graph API

  4. Hit check-out endpoint for graph API: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{item-id}/checkout

  5. if checkout is successful, then hit check-in endpoint: 4) Hit check-out endpoint for graph API: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{item-id}/checkin

with json as below, In our case, checkInAs as published turned out to be mandatory as without it, document was not getting checked in. But it can also work without this property is some case, depends on library settings:

image

Hope this helps.

Regards

Sonali

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.