Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

JSON Formatting at Runtime in HTTP Action

Posted on 20 Nov 2024 15:34:19 by 4

Hello everyone,

I am building a flow in Power Automate that uses an HTTP action with the POST method to send a raw JSON object to an external website. The JSON object follows this format:

{
"senderAlias": "Something",
"msisdn": "PhoneNumber",
"text": "Hello world"
}

According to the API documentation, I need to include a Content-MD5 header with a hash generated from the payload. While I can successfully send the payload without errors using Postman, I keep encountering the following error message in Power Automate:

"errorDescription": "Content-MD5 or RequestMD5 is required"
 

I have carefully reviewed the API documentation and confirmed that the header has been constructed correctly. Furthermore, to ensure the JSON payload is not altered at runtime, I have tried the following approaches, but the issue persists:

  1. Copied the JSON body output from the HTTP action and used it to generate an MD5 hash.

  2. Placed the payload in a Compose action and inserted it into the HTTP body.

  3. Used the following formula: replace(replace(replace(string(outputs('Compose_JSON')), ' ', ''), '\n', ''), '\t', '') in a new Compose action that takes the output from the previous mentioned Compose  to remove all whitespace and line breaks from the payload. I then copied the output to generate an MD5 hash.

Despite these attempts, I still receive the same error. I am beginning to suspect that Power Automate might be modifying the payload in the backend during runtime.

Has anyone encountered a similar issue or have any insights into why this might be so challenging?

  • Nived_Nambiar Profile Picture
    Nived_Nambiar 16,554 on 28 Nov 2024 at 02:11:59
    JSON Formatting at Runtime in HTTP Action
     
    if direct output from API was the issue - then Parse JSON is the solution.
     
    But as per your below response, not still clear around 
     
    I tried to use a parse json function that inherits the json from a compose action. I then placed the parse JSON body into the body of the HTTP action. Then i ran a test and converted the JSON to an md5 hash. Sadly I still get the same error. However i am not sure if i understood your suggestion correctly? 
     
     
    What my thought was use the parse JSON directly after API output- use the output from Parse JSON to hash generating systems -see whether that helps !
     
    Thanks & Regards,
    Nived N
  • SØ-20111539-0 Profile Picture
    SØ-20111539-0 4 on 27 Nov 2024 at 13:36:20
    JSON Formatting at Runtime in HTTP Action
    Hello again,
     
    Right now i am not even generating the hash automatically. I am just using md5hashgenerator to generate a hash and place that in the header for the content-md5. However once i get a successful run i will probably use Azure functions to handle the generation of an md5 hash automatically. 
  • Nived_Nambiar Profile Picture
    Nived_Nambiar 16,554 on 26 Nov 2024 at 02:07:14
    JSON Formatting at Runtime in HTTP Action
    Hi 
     
    Is it some external systems by which you are generating hash - or within another http action in power automate ?
     
     
  • SØ-20111539-0 Profile Picture
    SØ-20111539-0 4 on 25 Nov 2024 at 11:58:39
    JSON Formatting at Runtime in HTTP Action
    Hi, thank you for your answer :) 
     
    I tried to use a parse json function that inherits the json from a compose action. I then placed the parse JSON body into the body of the HTTP action. Then i ran a test and converted the JSON to an md5 hash. Sadly I still get the same error. However i am not sure if i understood your suggestion correctly? 

    Regards: Sakarias Ø
     
     
  • Nived_Nambiar Profile Picture
    Nived_Nambiar 16,554 on 20 Nov 2024 at 16:30:09
    JSON Formatting at Runtime in HTTP Action
    Hi,
     
    You can use Parse JSON action to parse body dynamic content from http action and after which you can apply hash function on it , see whether that helps !
     
    Thanks & Regards,
    Nived N

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,246

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,884

Leaderboard