Remove header return Owin WebApi

3

A simple return query to my REST service yields the following answer:

{
  "Id": 1,
  "Descricao": "TIROLESA DE AÇO",
  "Und": "UND",
  "Fabrica": "STARROW",
  "Estoque": 9,
  "Preco": 0.39
},

However, querying with more than one object starts with {"Result": [

{
"Result":   
[
  {
    ....
    ....
    ....
  } 
],
  "Id": 3,
  "Exception": null,
  "Status": 5,
  "IsCanceled": false,
  "IsCompleted": true,
  "CreationOptions": 0,
  "AsyncState": null,
  "IsFaulted": false
}

This last return has a "header" ( Result ) that makes it difficult to deserialize my class, would it be possible to configure the return so that it returns only Array JSON , without this header?     

asked by anonymous 01.08.2015 / 04:10

1 answer

1

I have found that the return of the JSON with header is related to the signature of the WebApi method that is called, for example:

If it is a method sincrono public List<Produto> GetAllProducts() return is:

[{
  "Id": 1,
  "Descricao": "TIROLESA DE AÇO",
  "Und": "UND",
  "Fabrica": "STARROW",
  "Estoque": 9,
  "Preco": 0.39
}]

If it is a method assincrono public public Task<List<Produto>> GetAllProductsAsync() return is:

{
"Result":   
[
  {
    ....
    ....
    ....
  } 
],
  "Id": 3,
  "Exception": null,
  "Status": 5,
  "IsCanceled": false,
  "IsCompleted": true,
  "CreationOptions": 0,
  "AsyncState": null,
  "IsFaulted": false
}
    
03.08.2015 / 14:51