The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I have a working API that when I hit from Query keeps returning 400 error no matter what I do. I understand that without showing API documentation which I dont have it might be hard to help but still I am asking for help. Here are some relevant details fom Postman.
My code:
api_url = "https://localhost:446/token",
body = "{ ""client_id"": ""xxxxxx"", ""username"": ""bba85b3d-5121-4439-8f3f-4c1a644bea5f"",
""client_secret"": ""xxxxxxxxxxxxxxxxxx"", ""grant_type"": ""password""}",
EncodedCredentials = Text.ToBinary(body),
Token_Response = Json.Document(Web.Contents(api_url,
[
Headers = [#"Content-Type"="application/x-www-form-urlencoded"],
Content=EncodedCredentials
]
)
)
No matter what I do, I get 400 back. In Postman misspelled parameters will generate an error message that comes back, but from PI I get nothing, just 400. Please help, I am stuck at this point.
Thanks
Solved! Go to Solution.
Finally figured it out. Here is how I am preparing parameters:
Text.ToBinary(Uri.BuildQueryString(body))
After that the backend gets proper parameters.
Finally figured it out. Here is how I am preparing parameters:
Text.ToBinary(Uri.BuildQueryString(body))
After that the backend gets proper parameters.
I finally was able to put a break point into API's code. What happens is that no parameters are available in the code. So, what exaclty is not working? Does Query actually send parameters?
I am using OAuth. Here is the funtion:
public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
conetxt is where I am checking for parameters. What I see is this:
when the same is called from Postman Results View has all the parameters.
User | Count |
---|---|
68 | |
63 | |
59 | |
54 | |
28 |
User | Count |
---|---|
182 | |
81 | |
64 | |
46 | |
38 |