im using system.net.httplistener to listen client requests, i start a process after receive request, the process do stuff and then return a response, using postman the process is started properly but wen i use XMLHttpRequest on javascript (with the same headers and body as the postman request) the process does not start. Using logfile the httplistener application reach the “p.Start();” line but does not start.
Do i need some specific header or body value? i think is about permissions but im not sure
Can you help me?
There is the Client Script code
function scan(path,foil) {
var url = "http://localhost:1300/ServicioEscaner/"; //direccion a donde se realiza el request
var method = "POST";
var shouldBeAsync = true;
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if ( request.readyState == request.DONE) {
if ( request.status === 200) {
alert(request.responseText);
}
}
}
request.open(method, url, shouldBeAsync);
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
request.send(JSON.stringify( {
"config":
{
"tag":
{
"value":foil,
"path":path,
"type":"scann"
}
}
}));
}
Did you tried adding [FromBody]
attribute to method parameter?
Tags: c++, http, java, javascriptjavascript, list