I need to make an ajax call by passing in the Header the following information: Content-Type: application / json Cookie: authToken = valueXPTO (This information above I got from Postman)
IneedtodothesamethingexceptIsawAjax,andnowayamIgettingit.Cananyonehelpme?
Followthecodebelow:
functionLogoutToken(){debugger;varurlApi=urlBase+"logout";
$.ajax({
type: "POST",
dataType: 'json',
url: urlApi,
crossDomain: true,
async: false,
contentType: "application/json; charset=utf-8",
beforeSend: function(xhr) {
xhr.setRequestHeader('Cookie', 'authToken=' + Token);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus);
alert('Falha na consulta de valores específicos, erro:' + textStatus);
},
success: function (msg) {
var xyx = msg;
}
});
}
When I run this way it gives the following error: Internal Server Error
In C # I execute as follows:
RestRequest request = new RestRequest(Method.POST);
request.AddCookie("authToken", token);