I have created a farm solutions to access external webservice an created a webpart. After deployed the solution it works fine. Then requirement has been changed. So I changed the application to sandboxed, it endsup with error. I debug the code and it returns an exception.
Request for the permission of type 'System.Net.WebPermission, System, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. This is my code where exception was thrown.
WebRequest req = WebRequest.Create(@"https://URL");
In my sharepoint site I find the below error in webpart.
Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.