How to debug this problem ?
This is my java code. I give permission for all ip by setting Access-Control-Allow-Origin, but still it says no "Access-Control-Allow-Origin"
return Response.ok().entity(jsonNodeToSend.toString()).header("Access-Control-Allow-Origin", "*").build();
This is my javascript code.
var dict = {
"clientMac" : "48:43:7c:53:53:d1",
"BSSID" : ""
};
$.ajax({
type: 'POST',
url: 'http://104.155.189.170:8080/Localization/rest/clientMacPosition/get/7',
crossDomain: true,
contentType: "application/json; charset=UTF-8",
data: dict,
dataType: 'json',
beforeSend: function(xhr) {
xhr.setRequestHeader('MessageId', 'abc123');
},
success: function(responseData, textStatus, messageId) {
console.log("success");
},
error: function(responseData, textStatus, errorThrown) {
console.log(textStatus);
console.log(responseData);
console.log(errorThrown);
}
});
Here is my method which gets the data and respond to the request.
@Path("/get/{customerProjectId}")
@POST
@Produces({ MediaType.APPLICATION_JSON })
public Response gettingRecentPosition(LocationAPIReceiverDTO locationAPIReceiverDTO,
@PathParam("customerProjectId") int customerProjectId) {
JsonNode jsonNodeToSend = null;
return Response.ok().entity(jsonNodeToSend.toString()).header("Access-Control-Allow-Origin", "*").build();
}
URL: http://104.155.189.170:8080/Localization/rest/clientMacPosition/get/7
jsonData : { "clientMac" : "48:43:7c:53:53:d1", "BSSID" : "33:" }
My REST call response in POST man.