Error consuming webservice

0

I have a webservice rest, now in c # I have a function that receives a json in string format and I send it to the webservice, but the webservice tells me that the json is wrong.

Can you tell me if it's wrong?

    ///xs
    var exPrecioStockConsulta = new List<Product>();
    exPrecioStockConsulta.Add(new Product()
    {
         //Algunos son int y otros string,estan en una clase Product
        comprobante_tipo = 1,
        emision = "30 - 04 - 2017",
        comprobante_moneda = 2,
        documento_tipo = 6,
        documento_numero = "123132132",

    });
  var json = new JavaScriptSerializer().Serialize(exPrecioStockConsulta);
   var request = (HttpWebRequest)WebRequest.Create("xxxxxxxxxxxx.com");
    var post1 = "data=" + json;
    var data = Encoding.ASCII.GetBytes(post1);
    request.Method = "POST";
    request.ContentType = "application/json";
    request.ContentLength = data.Length;

    using (var stream = request.GetRequestStream())
    {
        stream.Write(data, 0, data.Length);

    }
    var response = (HttpWebResponse)request.GetResponse();
    var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
    Console.WriteLine(responseString);
    Console.ReadKey();

This is the exit json:

[{
    "comprobante_tipo": 1,
    "emision": 30 - 04 - 2017,
    "moneda": 2,
    "documento_tipo": 2,
    "documento_numero": "123132132"
}]

The message I receive from the server tells me that the json is wrong just "Message: Error".

    
asked by franco vargas 09.05.2017 в 23:44
source

1 answer

3

The problem is the json:

"emision": 30 - 04 - 2017

It should be:

"emision": "30-04-2017"

Edit in this part:

exPrecioStockConsulta.Add(new Product()
    {
         //Algunos son int y otros string,estan en una clase Product
        comprobante_tipo = 1,
        emision = "30-04-2017", //Aqui anda tu error.
        comprobante_moneda = 2,
        documento_tipo = 6,
        documento_numero = "123132132",
    });
    
answered by 10.05.2017 / 00:07
source