I have the below code:
it returns internal server error,
but whenever I post "http://uk-postcodes.com/postcode/nearest?postcode=SE146NS&miles=1&format=json" directly to the browser
before running the code it runs fine.
If I run the code without posting directly to browser it returns internal server error.
Please is there anything I'm doing wrong
Code:
string baseUrl = "http://uk-postcodes.com/postcode/nearest";
string restUrl = string.Format("{0}?postcode={1}&miles={2}&format=json", baseUrl, postcode, miles);
HttpWebResponse response = null;
HttpWebRequest request = WebRequest.Create(restUrl) as HttpWebRequest;
request.Method = "GET";
request.Accept = "application/json";
request.ContentType = "application/json";
using (response = request.GetResponse() as HttpWebResponse)
{
var reader = new StreamReader(response.GetResponseStream());
if (response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Found)
{
string responseContent = reader.ReadToEnd();
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
postCodeWithRadiuses = javaScriptSerializer.Deserialize<List<PostCodeWithRadius>>(responseContent);
}
reader.Close();
}
I have the below code:
it returns internal server error,
but whenever I post "http://uk-postcodes.com/postcode/nearest?postcode=SE146NS&miles=1&format=json" directly to the browser
before running the code it runs fine.
If I run the code without posting directly to browser it returns internal server error.
Please is there anything I'm doing wrong
Code:
string baseUrl = "http://uk-postcodes.com/postcode/nearest";
string restUrl = string.Format("{0}?postcode={1}&miles={2}&format=json", baseUrl, postcode, miles);