I have a Web API project which returns json objects. The objects are populated correctly, but when they are received by the calling application, they are empty. I suspect this is to do with Json being denied for GET requests.
My API controller code looks like this:
public IHttpActionResult GetThing(string id)
{
try
{
var model = new Thing(id);
var res = Json<Thing>(model);
return res;
}
catch
{
return NotFound();
}
}
At this point "res" is correctly populated. Now on the other (client) side I have:
internal static JsonResult GetThing(string thingId)
{
return GetTask<JsonResult>(string.Format(ThingUrl, thingId));
}
When I check the value of the JsonObject here, it's empty (Data is null), but I also notice that the value of the field "JsonRequestBehavior" is "DenyGet" which I suspect is the issue.
My Question is, how do I set the value of this to be "AllowGet", so I can use the populated object? I'm losing what little hair I have left!