Oct 25 2018 02:02 AM
Is there a REST method to apply/update a retention label on a file in a library?
Oct 25 2018 03:55 AM
Oct 25 2018 04:02 AM
Yes, I did see that it was available through CSOM, but I was trying to figure out what would be the REST endpoint for this. Basically, I was trying to get the field updated from a Flow.
Nov 08 2018 09:30 AM
Joe can you please share the end to end scenario you are trying to achieve?
Nov 08 2018 07:26 PM
@cfiessinger I have site with retention Labels published on it. The document library in question uses these labels. There is a default label set as well. Based on the type/content of document users upload they change the label value to a more relevant one.
I was trying to automate some aspects of it by creating a Flow that will apply a specific Label based on lets say value of a column. Flow can call SharePoint Rest APIs easily, and hence the question.
Did not want to pass the call onto an Azure Function or something, but I know that is an option.
Nov 15 2018 02:51 PM
Did you ever find out if there is a REST API that could be used for this?
Nov 15 2018 03:46 PM
Not yet. Could not spend too much time on it yet. But still keen to find it out.
Nov 16 2018 09:12 AM
Solutionthanks, we are planning to release a REST API which will create the event-based retention by the end of year so stay tune (see this demo we did at Ignite: https://youtu.be/gBNcHJ7ERl8?t=2848
Feb 15 2019 08:10 AM
Yes we've made the following announcements on January 29th: Simplify processes and meet your requirements with new records management updates which includes document REST API for event based retention: https://docs.microsoft.com/en-us/office365/securitycompliance/automate-event-driven-retention
May 22 2019 11:35 AM
Sep 23 2019 07:43 AM
If you know the name of the retention label, you should be able to do this:
Use SPHttpClient and do a POST request to to https://mytenant.sharepoint.com/sites/someSite/_api/web/Lists/GetById('someLibraryGUID')/items/docum...()
Dec 05 2019 03:05 AM
@Silje Dahl Can you post a working example with exact HTTP headers, I have been trying but it doesn't seem to apply.
Others: There is a mention on this thread that this will be released as a supported mechanism in Flow by MS at some point, is it released now, I tried to find but can't find it yet.
Dec 05 2019 04:21 AM - edited Dec 05 2019 04:23 AM
@SukeshCrimson here is my JSON code from an HTTP call in Logic apps. It's possible you can perform a similar call in Flow as well, but I haven't tried as there is no direct code edit there.
"Apply_Label": {
"inputs": {
"body": {
"body": "{\n'complianceTag': '@{variables('MyComplianceTagName')}',\n'isTagPolicyHold': 'True',\n'isTagPolicyRecord': 'True'\n}",
"headers": {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
},
"method": "POST",
"uri": "_api/web/Lists/GetById('@{outputs('Library')}')/items(@{outputs('LocalDocId')})/SetComplianceTag()"
},
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "post",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent(outputs('DocSite')))}/httprequest"
},
"runAfter": {
"XYZ": [
"Succeeded"
]
},
"type": "ApiConnection"
}
The following is the input interpreted by Logic Apps, including the headers and body:
{
"method": "post",
"path": "/datasets/https%253A%252F%252FmyTenant.sharepoint.com%252Fsites%252FmySite/httprequest",
"host": {
"connection": {
"name": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MyRG/providers/Microsoft.Web/connections/sharepointonline"
}
},
"body": {
"body": "{\n'complianceTag': 'Exact label name',\n'isTagPolicyHold': 'True',\n'isTagPolicyRecord': 'True'\n}",
"headers": {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
},
"method": "POST",
"uri": "_api/web/Lists/GetById('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')/items(1234)/SetComplianceTag()"
}
}
Mar 05 2021 03:33 PM - edited Mar 05 2021 03:34 PM
can we also apply sensitivity labels on team site/folders using above api ?
Apr 01 2021 06:38 AM
Apr 01 2021 08:40 PM
I don't think there will be a license implication for using the REST API. Consuming the available API and implementing your own automations should not require any additional licensing..
Oct 17 2021 08:04 PM
Nov 09 2021 09:09 AM
@Rishi Gupta You can set the values today on the columns but we do have in the roadmap a REST API that makes labeling simpler, stay tuned for that.
Nov 16 2018 09:12 AM
Solutionthanks, we are planning to release a REST API which will create the event-based retention by the end of year so stay tune (see this demo we did at Ignite: https://youtu.be/gBNcHJ7ERl8?t=2848