cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
michowl
Microsoft
Microsoft

is flow malforming my json http request body?

I keep getting an error that indicates that my http request is missing a parameter, but input clearly indicates that the parameter has been passed. Is it possible that the JSON is being malformed somehow? Or am I missing something? See attached.

badrequest.JPG

 

Edit:

To answer some possible questions: (1) I'm authenticating to CRM because the actions I need to use are not exposed by Flow Actions (2) I've tried this exact same request in Postman and got a successful reply. I copy/pasted the values into Flow.

1 ACCEPTED SOLUTION

Accepted Solutions

It is because of the content type as Raj pointed out.  If you need to send a "application/x-www-form-urlencoded" payload you will need to send the body like the following:

grant_type=password&username=<url-encoded-username>&...

 

that should work.

View solution in original post

7 REPLIES 7
RajRa
Power Automate
Power Automate

can you send me the flow you used like so I can look it up

https://flow.microsoft.com/manage/flows/2ff01333-0ccb-450a-8aac-499da85766ce

 

Thanks

 

 

 

Sorry I'm just following up on this; I put this flow on the back burner for a while.

 

The flow id is: 90a21ba7-0344-47bb-bdd6-5093bc017abf

RajRa
Power Automate
Power Automate

We've made a lot of chagnes since you posted. Have you retried to see if this is still an issue?

I did. Output below. Looks like the same result as before:

 

REASON
  • Code
    BadRequest

INPUTS
  • Method
    POST
  • URI
  • Body
    {
       "grant_type": "password",
       "username": "[---------]",
       "password": "[---------]",
       "client_id": "[---------]",
       "resource": "https://[---------].crm.dynamics.com",
       "client_secret": "[---------]"
    }
  • Headers
    { "Cache-Control": "no-cache",
      "Content-Type": "application/x-www-form-urlencoded" }

OUTPUTS
  • Status code
    400
  • Headers
    {
       "Pragma": "no-cache",
       "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
       "X-Content-Type-Options": "nosniff",
       "x-ms-request-id": "c82f03f1-d0b9-416a-a11a-6187389e878e",
       "Cache-Control": "no-store, no-cache",
       "P3P": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"",
       "Set-Cookie": "x-ms-gateway-slice=006; path=/; secure; HttpOnly,stsservicecookie=ests; path=/",
       "Server": "Microsoft-IIS/8.5",
       "X-Powered-By": "ASP.NET",
       "Date": "Fri, 20 Jan 2017 19:35:29 GMT",
       "Content-Length": "435",
       "Content-Type": "application/json; charset=utf-8",
       "Expires": "-1"
    }
  • Body
    {
       "error": "invalid_request",
       "error_description": "AADSTS90014: The request body must contain the following parameter: 'grant_type'.
              Trace ID: c82f03f1-d0b9-416a-a11a-6187389e878e
              Correlation ID: feaf509b-055b-494f-93ea-4ec7fe014d81
              Timestamp: 2017-01-20 19:35:29Z",
       "error_codes": [ 90014 ],
       "timestamp": "2017-01-20 19:35:29Z",
       "trace_id": "c82f03f1-d0b9-416a-a11a-6187389e878e",
       "correlation_id": "feaf509b-055b-494f-93ea-4ec7fe014d81"
    }
 
RajRa
Power Automate
Power Automate

HI,

 

I'm unable to find your flow (did you delete it?) - And also have trouble recreating your exact scenario. One thing I noticed is your content type is incorrect - should it be applicatoin/json?

thanks

 

It is because of the content type as Raj pointed out.  If you need to send a "application/x-www-form-urlencoded" payload you will need to send the body like the following:

grant_type=password&username=<url-encoded-username>&...

 

that should work.

View solution in original post

thanks! Can't believe I missed that!

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (9,869)