SamiHuutoniemi
SamiHuutoniemi

Reputation: 1595

What more do I need for a HTTP GET request?

I'm trying to use a web api to download a page. A link to the api: http://api.arbetsformedlingen.se/

If I use code like:

HttpClient c = new HttpClient();

c.BaseAddress = new Uri("http://api.arbetsformedlingen.se/");
var response = c.GetAsync("platsannons/soklista/kommuner?lanid=10").Result;

The request looks like:

 {Method: GET, RequestUri: 'http://api.arbetsformedlingen.se/platsannons/soklista/kommuner?lanid=10', Version: 1.1, Content: <null>, Headers:{}}

Shouldn't this be enough to get a valid response? What I do get is a 400 Bad request:

StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:{  Connection: close  Proxy-Connection: keep-alive  Date: Fri, 28 Jun 2013 10:02:34 GMT  Server: Apache  Content-Length: 117  Content-Type: application/json; charset=UTF-8}

Do I need to have something in the Content?

Upvotes: 0

Views: 997

Answers (1)

CodeCaster
CodeCaster

Reputation: 151586

Shouldn't this be enough to get a valid response?

That totally depends on the server. Try to compare your request with a "real" request issued from a browser, for example using Fiddler, and spot the differences. The server might block automated requests by returning a 400.

Upvotes: 2

Related Questions