0

I know that AngularJS prefers JSON, but I can't get my Web API to work with JSON. I've tried for 3 days and I'm not going to try anymore. I can get it to return XML. Can I retrieve the XML data with AngularJS? I have written the $http call below and it always fails with no status text. I've tried asking for XML type and I've tried the default call. You can see that all 3 of these URLs return XML data in the browser:

http://stevegaines.info/api/Exams?id=3&extra=0
http://stevegaines.info/api/Exams/4
http://stevegaines.info/api/values


$http.get(url)
    .then(function (dataResponse)
    {
        $scope.Exams = dataResponse.data;
    }, function (error)
    {
        alert("error.statusText = " + error.statusText);
    });

1 Answer 1

1

I've just tried to call your api with $http service and it works ok. I think you should start investigating this problem with looking at network tab in chrome developer tools when making such a request.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for giving it a try. I'm surprised that it worked for you. I'm going to try checking the network tab again, but every time I dug into the response it just said "An error has occurred". Maybe I'll try creating a new project that has nothing but that one line of code to be sure something else in my code is not causing the problem.
I tried calling this URL again and discovered, that you need add www. to your address, because e.g. get request on http://stevegaines.info/api/Exams?id=3&extra=0 returns 301 response moved permanently, so no data can be parsed. I think it helps.
Brilliant. Adding "www." worked. Such a little change. That's one of those things where I go "Doh!". Or "Why didn't I think of that?" Thanks a lot.

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.