Forum Discussion
Oauth 2.0: Session API Token Request Fails with Special Chrs in Body?!? (Rest API)
- Anonymous6 years ago
artemus , thank you for all of your help troubleshooting this issue!!! It's insanely valuable and been absolutely appreciated. I wanted to let you (as well as others that see this thread) know that we were able to resolve the issue. I contacted the vendor after our multiple attempts and it was determined the API had a bug. Your code was 100% correct and works flawlessly!
Thank you again!
-Brett
So... I'm guessing, but would that connector would mean the report has to reside on the desktop at all times?!? While I have Power BI Desktop, we need the reports to run in the cloud on Teams and such.
The code looks nearly identical to what we have already written...
Are we able to rule out it isn't the special characters, compression, or encoding causing the trouble?
I think the main difference is the headers passed in. I.e. it says use Json
As far as I mentioned, if you use a custom connector and you want it to refresh itself, you would need to set up an enterprise gateway which would let you install the custom connector on it.
- Anonymous6 years agoNot applicable
Where do you see it saying "use Json"? In the code you linked or elsewhere? I could give that a try...
- artemus6 years ago
Microsoft Employee
It is here (line 154): https://github.com/microsoft/DataConnectors/blob/dbd99078501897e04e7a6b9305ad7857ae1b7a63/samples/Github/github.pq#L154
The request headers are different in this example
- Anonymous6 years agoNot applicable
That's a great call out. I tried it, didn't help or hurt. Reviewing the API, I think it has to do with URL encoding, but I don't know the syntax. Right now it reads:
body = Uri.BuildQueryString([Username="VALUE1", Password="VALUE2!", grant_type="password", Integrated="N", database="VALUE3", Client_Id="VAL+UE4=", client_secret="VALUE5"]),
I'm concerned about the blue highlighted values.
The API provides an encoding chart and also mentions some values might need to be URL-escaped (looking that up now). But doesn't provide syntax or context on either one.
Special CharacterEncoded Value
space [ ] . [.] * [_ASTERISK_] / [_$2F_] \ [_$5C_] & [_$26_] ? [_$3F_] + [_$2B_] = [_$3D_] # [_$23_] % [_$25_] [ [_$5B_]