-1
I’m taking this header from the Fiddler.
POST http://localhost:8887/api/values HTTP/1.1
Host: localhost:8887
Proxy-Connection: keep-alive
Content-Length: 352
Accept: */*
Origin: http://localhost:8383
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://localhost:8383/comandaApp/principal.html
Accept-Encoding: gzip, deflate
Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4
{"IDEmpresa":"1","IDTabelaPreco":"1","numeroVendedor":"1","IDCupomFiscal":"","IDGrupo":"1","IDUsuario":"1","IDVendedor":"1","NMMesa":"3","IDMesa":"3","STCartao":"N","STViagem":"N","STDelivery":"N","modalidadeDelivery":"","observacaoDelivery":"","localEntrega":"","comandaItemPojo":[{"IDProduto":"162","NRReferencia":"","QTDProduto":1,"observacao":""}]}
Sending to the webAPI
$.ajax({
type: 'POST',
crossDomain: true,
url: "http://localhost:8887/api/values",
data: JSON.stringify(comandaPojo),
success: function(retorno)
{
//códigos....
}
In the WEBAPI is like this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Mvc;
namespace webapi_MVC5.Controllers
{
public class ValuesController : ApiController
{
public void Post([FromBody]string value)
{
string a = value; //VALUE RETORNA NULL
string b = "x";
}
}
}
I’ve already added this line to webconfig
<add name="Access-Control-Allow-Origin" value="*" />
I only get NULL in the parameter value.
What can it be? my IIS is logged in as my local user (with password). It has something to do with?
you really want to catch the JSON string?
– Joel Ramos Michaliszen
what has in
comandaPojo? what is the content?– novic