When running a service: the following error occurs. Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value [closed]

2

FrameWork 4.0 Code block that generates error

var token = Configuracao.Config.TokenAgrometrika;

if (Configuracao.Config.ValidateTokenAgrometrika > DateTime.Now) return token;

   var autenticacao = new Autenticacao()
   {
        Chave = Configuracao.Config.ChaveAgrometrika,
        ID = Configuracao.Config.IdAgrometrika
   };
Tools.Log(string.Format("Pegando token de autorização. Chave: {0} ID: {1}", autenticacao.Chave, autenticacao.ID));

var _cliente = new HttpClient(Handler, true);                   
var url = Configuracao.Config.Url.EndsWith("/") ? Configuracao.Config.Url : Configuracao.Config.Url + "/";

if (!Configuracao.Config.Url.EndsWith("api/") && !Configuracao.Config.Url.EndsWith("APIv2/"))
{
    url = Configuracao.Config.Url + "api/";                       
}                    
_cliente.BaseAddress = new Uri(url);
_cliente.DefaultRequestHeaders.Accept.Clear();
_cliente.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

*{Error happens here}*

var response = _cliente.PostAsJsonAsync("Autenticacao", autenticacao).Result;

Error after response.

  

Error: Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value:

asked by anonymous 29.03.2017 / 22:18

0 answers