Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post

(1) ShareShare
ReportReport
Posted on by 63

Hey everyone, 

 

I am running into a very odd issue in regards to automating Retention Labels in a flow. 

 

I have tried two approaches: 


1) Utilizing a M365 Compliance "Apply Label on the Item" action which regardless of the formatting, always seems to result in a "The Response is not in a JSON Format" - not sure how to alleviate this or how to work around this

Screenshot 2022-11-11 at 4.04.06 PM.png

The output from the body reads as:

{
 "error": {
 "code": 403,
 "source": "flow-apim-unitedstates-002-westus-01.azure-apim.net",
 "clientRequestId": "51e5bb68-f94c-4026-ab82-b063d3285353",
 "message": "The response is not in a JSON format.",
 "innerError": "Cannot read server response."
 }
}



2) Using the usual "Send HTTP Request to Sharepoint" with the /setComplianceTag() method which leads to multiple retries on the action due to a "Bad Gateway" - this one is particularly confusing as I have a separate but similar action right before (not with the /setComplianceTag()) that runs fine without issues.  

Screenshot 2022-11-11 at 4.05.50 PM.png

Any form of help or guidance would be greatly appreciated - TIA 🙂



 

  • sandeepstw Profile Picture
    302 Super User 2025 Season 1 on at
    Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post
    Hi
  • AW-07080843-0 Profile Picture
    9 on at
    Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post
    I'm getting the same error with the compliance connector, sad to see that this issue is still present after 3 years.
  • Verified answer
    pricelesstarget Profile Picture
    63 on at
    Re: Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post

    Following up on this incase anyone else runs into this issue

    Long story short, we ended up getting the HTTP Request to work - turns out it was a permissions issue with the user that was connected - either way, thank you @Expiscornovus for the assist 🙂

  • pricelesstarget Profile Picture
    63 on at
    Re: Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post

    Oh yep @Expiscornovus , I caught that as I was removing the quotes from the boolean values; appreciate the call out!

    And just using a drop down value value for the site address

  • Expiscornovus Profile Picture
    32,131 Most Valuable Professional on at
    Re: Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post

    Hi @pricelesstarget,

     

    Just a heads-up. Just reviewed one of your previous screenshots again, you are missing a comma after your isTagSuperLock.

     

    Don't know if you missed that when removing the quotes. Worth double checking.

     

    And are you using a custom site address or did you simply select the site from the dropdown?

     

    missingonecomma.png

  • pricelesstarget Profile Picture
    63 on at
    Re: Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post

    Hey @Expiscornovus , I appreciate the quick follow-up!

    I made the edit and entered the ID without quotes as you mentioned and am still getting the BadGateway error unfortunately-I will make the update to the Apply Label to pass the GUID instead of the List ID and follow up with the outcome there as well

    Again, greatly appreciate your support and help on this issue 🙂  

  • Expiscornovus Profile Picture
    32,131 Most Valuable Professional on at
    Re: Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post

    Hi @pricelesstarget,

     

    I did not notice before, but in the items you used quotes. The Items() also expects a number value without quotes. 

     

    itemid_02.png

     

    So, if the ID of your specific file is 1 the URI value should look like below:

    _api/web/lists/GetByTitle('Documents')/items(1)/SetComplianceTag()

     

    itemid.png

    In the Appy to label on the item it is a different id, that is actually a GUID and not a number.

     

     

     

  • pricelesstarget Profile Picture
    63 on at
    Re: Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post

    Hey @Expiscornovus ,

    I followed the suggestion you provided of not using the double quotes for the boolean values, and the same error still occurs of a "BadGateway"

    And the inputs for the Apply Label action are below. 

    Screenshot 2022-11-11 at 2.48.26 PM.png

     

    Thank you!

  • Expiscornovus Profile Picture
    32,131 Most Valuable Professional on at
    Re: Unable to apply Retention Labels using either M365 Compliance Action or HTTP Post

    Hi @pricelesstarget,

     

    Can you use a Body where the boolean properties values are without quotes in the Send an HTTP request?

     

    Try something like below:

    {
    "complianceTag":"TEST 1 Year Rolling Retention - WORM - CLA",
    "isTagPolicyHold":false,
    "isTagPolicyRecord":false,
    "isEventBasedTag":false,
    "isTagSuperLock":false,
    "isUnlockedAsDefault":false
    }

     

    Could you share a screenshot of the setup of the Apply Label on the Item action? This will help to troubleshoot what the root cause is of that specific issue.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1