Forum Discussion
DevinL
2 years agoHelper I
Trouble with Request Body in Copy Data data flow
I'm connecting to a REST API through a POST request and trying to pass some parameters (filters) in the request body: {
"size": 100,
"page": 1,
"search": {
"date_limits": [
{
...
Anonymous
2 years agoNot applicable
Hi DevinL,
Have you try to put these processing in M queries with web connector and optional parameter and 'relative path'?
let
//API endpoint
url = "",
// request headers
headers = [#"Content-Type" = "application/json", #"Authorization" = "Bearer your_api_key"],
//Relative path
path = "credits/debits/accounts/xxxx",
// query
query = "{
'size': 100,
'page': 1,
'search': {
'date_limits': [
{
'field': 'datetime',
'from': '2024-06-25 00:00:00',
'to': '2024-07-01 00:00:00'
}
]
}
}",
// Get the data from the API
rawData = Web.Contents(url, [
Headers = headers,
RelativePath = path,
Content = Text.ToBinary(query)
]),
// Convert the JSON response into a table
json = Json.Document(rawData),
#"Converted to Table" = Record.ToTable(json)
in
#"Converted to Table"
Using The RelativePath And Query Options With Web.Contents() In Power Query And Power BI M Code
Regards,
Xiaoxin Sheng
DevinL
2 years agoHelper I
Thanks for the reply.
Getting an error though: DataSource.Error: Web.Contents failed to get contents from 'https://apiaddressishere/search/credits' (422): Unprocessable Entity