In my java webapplication i have added a webservice call @ URL 10.10.10.21:8088/openbravo/com.data.service.
When i hit the URL from browser, it asks me for a Username and password. After entering those details, i can see the json output (desired output).
The web service provides a JSON REST service. I want to implement a basic client UI to fetch this JSON data and publish on the page. As a part of client i have written basic html code with jQuery ajax to make call to this URL. But i get 401 unauthorized response.
$("input#add-contact").on("click", function () {
$.ajax({
type: "POST",
url: "http://10.10.10.21:8088/openbravo/com.indavest.openbravo.restaurantpos.service",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
console.log(response);
}
});
});
How can i add the authentication headers to the call. Is the above lines of code the right approach to make call to the rest webservice. I am new to the Webservices concepts. Any help would be great!!! Thanks.