I'm using ApiController and I can't get the call to return anything other than XML.

public class GuideController : ApiController
{
    [AcceptVerbs("GET")]

    [HttpGet]
    public string Get()
    {
        Item item = Item.GetTestData();
        string json = JsonConvert.SerializeObject(item);
        return json;
    }
}

Ideally, I want to return JSON normally but I'd settle for returning raw strings instead of XML wrapped ones.

share|improve this question
    
What is the accept header of the request? – Jason Boyd 7 mins ago

Try setting the Accept header in the client. If you want to receive JSON, set

Accept: application/json

in your client. Hope that helps.

share

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.