Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello! I'm having trouble to get a response from an API which receives GET methods but also asks for content using M (trying to wrap it in a Custom Connector). I can get a sample response on it with curl by using:
curl -X GET "https://api.salaovip.com.br/reports/0005?page=1&limit=100" ^
-H "Content-Type:application/json" ^
-H "Authorization: MY_API_KEY" ^
-d "{\"params\": [{ \"name\": \"inicio\", \"value\": \"01/01/2020\" }, { \"name\": \"fim\", \"value\": \"03/02/2020\" }]}"
So, when I try to do it with M it doesn't work, I guess Web.Contents automatically send it as a POST method when I use a header with "Content-Type", since I receive a 405 status code with "Method not allowed". I tried to use the WebAction.Request(WebMethod.Get, url, options) function, but in the Visual Studio it won't leave the Credential Set screen, and always gives me an "We haven't been given permissions to perform actions against this XXXX source."
Is there a way to send a GET request while keeping the "-d" part of it?
Hi @fdanielsouza ,
let
content = "{
""method"": ""get"",
""params"": {
""SelectionCriteria"": {},
""FieldNames"": [""Id"", ""Name""]
}
}",
Source = Json.Document(Web.Contents("https://api.salaovip.com.br/reports/0005?page=1&limit=100", [Headers=[Authorization="Bearer AQAAAAANlKwBAAQQn4Wfgbxxxxxxxxxx"], Content=Text.ToBinary(content)]))
in
Source
try these code above with adjusted parameter Bearer etc. it should work
-------------------------------------------------------------------
Did I answer your question? Mark my post as a solution!
It was useful? Press Thumbs Up!
@rainer1 , thank you for the help and sorry I'm replying late, please look if this is what you meant me to do, because it still raises the 405 status error
Have you tried manual status handling? E.g.:
= Value.Metadata(Web.Contents("https://example.com", [ManualStatusHandling={405}, Content=Text.ToBinary("<Content>")]))[Content.Uri]()
Artemus, thank you for your help. I can get the metadata after ManualStatusHandling, but I don't know where to go after that. Can't just use Web.Contents again using the Content.Uri, also can't use the Location header in the request because the response status isn't 300ish.
I think the solution would be using the WebAction.Request() function, but I always get an "We haven't been given permission to perform actions against this source" error on VS and "Object reference not set to an instance of an object" error on Power BI Desktop.
When you do manual redirect handling, then the Contents.Uri will be transformed into a GET request (for most status codes).
Hmm, understood artemus! Should [Contents.Uri]() bring me the the content of the request if it was a GET or should I use it in another request? Right now it brings me the URL in text format.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |