3

Based on this code below from previous support:

 using (WebClient client = new WebClient())
 {
     client.Headers.Add("Accept-Language", " en-US");
     client.Headers.Add("Accept", " text/html, application/xhtml+xml, */*");
     client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");

     XDocument xml = XDocument.Parse(client.DownloadString("http://api.arbetsformedlingen.se/af/v0/platsannonser/matchning?lanid=1&kommunid=180&yrkesid=2419&1&antalrader=10000"));
 }

I retrieve a error message

{System.Xml.XmlException} {"Data at the root level is invalid. Line 1, position 1."}

I tried solving it but I cannot find a solution to it.

1 Answer 1

3

You're actually getting a json, change the following:

client.Headers.Add("Accept", " text/html, application/xhtml+xml, */*");

to

client.Headers.Add("Accept", "application/xml");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.