Forum Discussion
digiroo
9 years agoFrequent Visitor
M Query to use POST method on a Web API
Hi I'm trying to get a POST method to work on the Sage One API. GET method works fine, POST method requires the web.content,[Contents] option. Im trying to work through the options. From var...
Anonymous
3 years agoNot applicable
Hello Eric_Zhang,
I'm trying to implement such request on Clockify API.
https://docs.clockify.me/#tag/Time-Entry-Report/operation/generateSummaryReport
= let
#"URL" = "https://reports.api.clockify.me/v1/workspaces/63be77bd5e398c3868773063/reports/summary",
#"body" = "{
""dateRangeStart"": ""2023-01-01T00:00:00.000Z"",
""dateRangeEnd"": ""2023-12-31T23:59:59.000Z"",
""summaryFilter"": {""groups"": [""USER""]},
""exportType"": ""JSON"",
"users": {
"ids": ["63be77bd5e398c3868773062","637379b66c975d7d01ebceea","64104151cd49c235581406fb","63c54ec6d6bbe005e2c42677"],
""contains"": ""CONTAINS"",
""status"": ""ALL""
}
}",
#"Parsed_JSON" = Json.Document(#"body"),
#"BuildQueryString" = Uri.BuildQueryString(#"Parsed_JSON"),
Source = Json.Document(Web.Contents(#"URL",
[Headers=[Accept="application/json", #"x-api-key"="XXXX"], Content = Text.ToBinary(#"body")])),
#"Converted to Table" = Table.FromColumns({Source})
in
Source"X-API-KEY"="XXXX" where XXXX is my API Key
I think i'm following what you have done, but i get an 415 error.
DataSource.Error : Web.Contents n'a pas réussi à obtenir le contenu de « https://reports.api.clockify.me/v1/workspaces/63be77bd5e398c3868773063/reports/summary » (415) : Unsupported Media Type
Détails :
DataSourceKind=Web
DataSourcePath=https://reports.api.clockify.me/v1/workspaces/63be77bd5e398c3868773063/reports/summary
Url=https://reports.api.clockify.me/v1/workspaces/63be77bd5e398c3868773063/reports/summary
But on Postman, it works as a charm :
I don't get what is the meaning of 415 error and why i get it.
Would be really helpful if you can help.
Kind regards
Fabien
Anonymous
3 years agoNot applicable
Hello,
Is there anyone that could help ? I compared what I have done with https://developers.de/2021/10/11/how-to-send-the-post-request-in-powe-query/ and it seems identic.
Kind regards