Quantcast
Channel: Current Observation feed from weather.gov forbidden (403) - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Answer by Jim Speaker for Current Observation feed from weather.gov forbidden (403)

$
0
0

Contacting weather.gov resulted in a really fast response, which was:

Applications accessing resources on weather.gov now need to provide a User-Agent header in any HTTP request. Requests without a user agent are automatically blocked. We have implemented this usage policy due to a small number of clients utilizing resources far in excess of what most would consider reasonable.

We recommend providing a user agent string in the following format:

ApplicationName/vX.Y (http://your.app.url/; contact.email@example.com)

This will both uniquely identify your application and allow us to contact you and work with you if we observe abnormal application behavior that may result in a block.

Please feel free to email us back if you continue to have issues after verifying that your application is sending the proper headers.

Thanks for using weather.gov.

=======

Here's a snip of C# code. The key thing is that you need to create the request object then append a custom User-Agent string to it before making the call.

...var request = new HttpRequestMessage(HttpMethod.Post, httpClient.BaseAddress.AbsoluteUri);request.Headers.Add("User-Agent", "MyApplication/v1.0 (http://foo.bar.baz; foo@bar.baz)");var httpResponse = httpClient.SendAsync(request).Result;...

Hope this helps folks.Cheers


Viewing all articles
Browse latest Browse all 6

Trending Articles