RestFul JSON Service

3

I'm doing a restful service, it returns data like json but but inside an xml and I only want json . Annex image of how the result looks. and my code. I want to remove the highlighted in yellow.

namespace WcfServiceWOM
{
    [ServiceContract]
    public interface IService1
    {

        [OperationContract]
        [WebGet]
        string GetDataUsingMethod(string rut, string idCliente, string top);

        [OperationContract]
        [WebGet(UriTemplate = "/GetData/rut={rut}&idCliente={idCliente}&top={top}")]
        List<ItemOmniVM> GetDataUsingURI(string rut, string idCliente, string top);
    }
}

    public class Service1 : IService1
    {
        public string GetDataUsingMethod(string rut, string idCliente, string top)
        {
            List<ItemOmniVM> list = new ItemOmniDao().read(rut, idCliente, top);

            var json = JsonConvert.SerializeObject(list);
            return json;
        }
        public List<ItemOmniVM> GetDataUsingURI(string rut, string idCliente, string top)
        {
            List<ItemOmniVM> list = new ItemOmniDao().read(rut, idCliente, top);

            return list;
        }


    }
    
asked by Alexandra Teran 17.05.2018 в 22:53
source

1 answer

0

You would be missing an adornment to the attributes of your WebGet. It would be like this:

[ServiceContract]
public interface IService1
{
    [OperationContract]
    [WebGet(ResponseFormat= WebMessageFormat.Json)]
    string GetDataUsingMethod(string rut, string idCliente, string top);

    [OperationContract]
    [WebGet(ResponseFormat= WebMessageFormat.Json, UriTemplate = "/GetData/rut={rut}&idCliente={idCliente}&top={top}")]
    List<ItemOmniVM> GetDataUsingURI(string rut, string idCliente, string top);
}

I hope it's useful

    
answered by 18.05.2018 / 16:07
source