I need to simulate this curl command
curl -i -H "Accept: application/json" -H "Content-type:application/json" -X POST -d '{"username":"pippo","password":"secret123"}' http://url.org/api/login
through jquery i did this way
$( document ).ready(function() {
$.ajax({
url:"http://urlapi/user/login",
type:"POST",
headers: {
"Accept" : "application/json; charset=utf-8",
"Content-Type": "application/json; charset=utf-8"
},
data:{ username: "pippo", password: "secret123" },
dataType:"json"
})
});
I still have text text / html. Correctly?
source
share