I'm trying to send a very simple Ajax POST request with basic authentication to a REST API. With Postman all seems to be OK, but when I do it through my webpage using jQuery, I'm getting a 401 error.
After several other attempts, currently this is my code:
$.ajax({
type: 'POST',
url: 'http://admin:admin@my_rest_api_url',
data: { "name":"John","surname":"Doe" },
crossDomain: true
});
Any suggestions are very welcome.