`Public Function STSCall() As String Dim url As String = "https://httpbin.org/get?token=8041637103881119" Dim cardNumber As String = String.Empty Dim httpWebRequest = CType(System.Net.WebRequest.Create(url), System.Net.HttpWebRequest) httpWebRequest.Method = "GET" httpWebRequest.ContentType = "application/json" httpWebRequest.Headers.Add("X-AuthMode", "ServerSimpleAuth") httpWebRequest.Headers.Add("X-ServerAuthKey", "STS") Dim response = CType(httpWebRequest.GetResponse(), System.Net.HttpWebResponse)
Dim StreamReader As New System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.ASCII)
cardNumber = StreamReader.ToString()
Return cardNumber
End Function`
I need to call a web API from RDL file which is present in the reporting project hosted in SSRS. There is one field in the RDL report which will consume a Web Api response. I have written code in RDL to call that api and get the response using System.net Library but it is getting failed due to some System.Web.permission error.
I have tried to consume the web api using below code written in VB.NET (Target framework version 2.0).I also tried to set trustlevel = full in web.config but that doesn't work and still getting permission denied error. I am getting successful web api response on executing the same code with httpWebRequest..etc from console application but it fails when I try to call from RDL. Please let me know how to fix the System.net library permission error.
Getting below error while invoking the above function to consume web api response. System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand()
Aucun commentaire:
Enregistrer un commentaire