1 year ago
#359847

Guillaume Leseur
Why does HttpWebResponse behave differently when integrated to Power BI Report Server custom security project?
I developped a Custom Security extension for Power BI Report Server as we needed a token validation process to athenticate users.
I coded a method in a C#.NET project which works on both dev and test environments. You guessed it, pushing this to production does not work, unfortunately. The method is simple it returns True if when calling an API, the Http status code is 200, false otherwise.
Now the strange behaviour is: If I copy/paste this method on a new project on the production machine and execute this method only, it works ! So it does not seem to be a machine related issue.
I'm pretty sure it's just something silly I'm missing but I'm honestly out of ideas. Any suggestion on what could change when integrating this piece of code within the C# .NET project would be greatly appreciated:
internal static bool VerifyToken(string suppliedToken)
{
String url = Environment.GetEnvironmentVariable("PBI_token_orafr", EnvironmentVariableTarget.Machine).ToString();
//string token = "myToken";
WebRequest request = WebRequest.Create(url);
request.Method = "GET";
request.Headers.Add("Authorization", suppliedToken);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if ((int)response.StatusCode == 200)
{
response.Close();
return true;
}
else
{
response.Close();
return false;
}
}
Things I already tried:
- Setting a hard coded token thinking my parameter "suppliedToken" was wrong -> does not work
- Trying to log something with StreamWriter -> does not work
c#
powerbi
httpwebrequest
power-bi-report-server
0 Answers
Your Answer