I had the following webclient request
WebClient serviceRequest = new WebClient();
var JsonResponse = serviceRequest.DownloadString(new Uri(urselected));
Where urselected was the REST query string. The query worked fine in my browser but returned 403 forbidden error. I found the following post which addresses the problem:
Wikipedia query returns error 403
Modified my code as follows and it worked find:
WebClient serviceRequest = new WebClient();
serviceRequest.Headers.Add("user-agent", "Silver Azure");
var JsonResponse = serviceRequest.DownloadString(new Uri(urselected));
No comments:
Post a Comment