Forum Discussion
JackSoderstrom
Helper I
5 years agoM language how to get this header to work?
Trying to create a custom connector but can't with this header for some reason. Not sure how to use it correctly. This works just fine as a GET request shared Connector.Contents = () =>
...
- 5 years ago
That's not how POST works in Web.Contents()
Content: Specifying this value changes the web request from a GET to a POST, using the value of the option as the content of the POST.
JackSoderstrom
Helper I
5 years agoHey, Thank you for the reply. How do POST requests work with Web.Contents? Should I be formatting it like so?
let
url = "URL",
apiKey = Extension.CurrentCredential()[Key],
headers = [
#"Authorization" = Text.Combine({"Bearer ", apiKey}),
#"Content-Type" = "application/json ; charset=utf-8",
#"Version" = "2021-08-16"
],
request = Web.Contents(url, [ Headers = headers, ManualCredentials = true , Content = Text.ToBinary("POST")])
in
request;
I Get a 400 Bad Request with this
lbendlin
Super User
5 years agoinstead of
Content = Text.ToBinary("POST")
you need to specify the actual payload
Content = Text.ToBinary(payload)
Here is an example of how to structure the payload string
M Query to use POST method on a Web API - Microsoft Power BI Community