Forum Discussion
jm420a
3 years agoFrequent Visitor
HTTP POST To API for query source - Passing Parameters to API using Power Automate POST URL
Greetings, I have an API Call that works fine in Postman when specifiying parameters, however, when I try to post to the same URL, passing the parameters in PQ, I receive a 400 Bad Request error. I'm...
- 3 years ago
Hi jm420a ,
yes, you are mixing M- and JSON-syntax here:
In M, a record is defined using square brackets instead of curly ones in JSON.
And when using the Json.FromValue-function, you have to pass M-code to it.
So removing the curly brackets in there, should hopefully do the trick:let PostURL = "https://prod-59.westus.logic.azure.com:443/workflows/281583e6ee6b45d6705dfaa8531/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=W1O8t6yfYjcXLPsmKZdmE7PsvxFWtZUjz2miFY" , AccessKey2 = "aaaaa-bbbbb-ccccc-ddddd-eeeee" , TenantURL2= "https://yourtenant.sharepoint.com" , Source = Json.Document( Web.Contents( PostURL , [Headers=[#"content-type"="application/json"] , Content = Json.FromValue( [AccessKey=AccessKey2,TenantURL=TenantURL2] ) ] ) ) in Source
ImkeF
Community Champion
3 years agoHi jm420a ,
yes, you are mixing M- and JSON-syntax here:
In M, a record is defined using square brackets instead of curly ones in JSON.
And when using the Json.FromValue-function, you have to pass M-code to it.
So removing the curly brackets in there, should hopefully do the trick:
let
PostURL = "https://prod-59.westus.logic.azure.com:443/workflows/281583e6ee6b45d6705dfaa8531/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=W1O8t6yfYjcXLPsmKZdmE7PsvxFWtZUjz2miFY"
, AccessKey2 = "aaaaa-bbbbb-ccccc-ddddd-eeeee"
, TenantURL2= "https://yourtenant.sharepoint.com"
, Source = Json.Document(
Web.Contents(
PostURL
, [Headers=[#"content-type"="application/json"]
, Content =
Json.FromValue(
[AccessKey=AccessKey2,TenantURL=TenantURL2]
)
]
)
)
in Source