Trying to reach a web service URL, works (returns status code 200 as expected) without issue with simple GET from a browser but when executing through console application it is returns status code of 500? I suspect it's proxy or DNS issue but unsure...
Here's request creation from console app:
// webRequestUrl has been modified
const string webRequestUrl = "http://0.0.0.0/communication/?id={0}&status=70"
var webRequest = WebRequest.Create(string.Format(webRequestUrl, invalidSseLead.LeadId));
try
{
using (var webResponse = (HttpWebResponse)webRequest.GetResponse())
{
if (webResponse != null && webResponse.StatusCode == HttpStatusCode.OK)
{
using (var textStream = new StreamWriter("updateQuery.sql", true))
{
// Write some text
}
}
}
}
catch (Exception exception)
{
// Report exception
}
Have checked request URL being generated and it's f开发者_开发知识库ine, stumped why it works from browser but not console app?
Thanks :)
Is the site rejecting programmatic access such that you maybe have to fake your user agent using the following?
webRequest.UserAgent = "some normal browser user agent string";
Thanks for the assistance. Turned out the problem was in fact with the URL, one worked however a different one being generated was throwing the exception.
+1 to MSMS - I really needed to copy and paste out the exact URL being generated rather than using one with test data
Thanks
精彩评论