I got below error in ajax request to REST api
"NetworkError: 400 Bad Request - http://192.168.2.45:8080/engine-rest/external-task/fetchAndLock/?callback=jQuery111008749113014618789_1478158463319&{%22workerId%22:%22worker01%22,%22maxTasks%22:5,%22topics%22:[{%22topicName%22:%22correctionOfData%22,%22lockDuration%22:10000,%22variables%22:[%22Applicant_Name%22]}]}&_=1478158463320" ?callba...8463320
Ajax code
<script type="text/javascript">
require(['jquery'],function($) {
var REST_BASE_URL = "http://192.168.2.45:8080/engine-rest";
function receiveExternalTasks(topicName) {
var fetchRequest = {
"workerId":"worker01",
"maxTasks":5,
"topics": [
{
"topicName": topicName,
"lockDuration": 10000,
"variables": ["Applicant_Name"]
}
]
}
$.ajax(REST_BASE_URL + '/external-task/fetchAndLock/', {
data: JSON.stringify(fetchRequest),
dataType : "jsonp",
contentType: "application/json; charset=utf-8",
type : 'POST',
beforeSend: function(xhr){xhr.setRequestHeader('Access-Control-Allow-Origin', '*');},
success: function (result) {
for (var index = 0; index < result.length; ++index) {
var externalTask = result[index];
console.log(externalTask);
addRowToTable('table' + topicName, JSON.stringify(externalTask));
$.ajax(REST_BASE_URL + '/external-task/' + externalTask.id + '/complete', {
data: JSON.stringify({"workerId":"worker01"}),
dataType : "jsonp",
contentType: "application/json; charset=utf-8",
type : 'POST'
});
}
}
});
};
$(document).ready(function(){
$("button").click(function(){
receiveExternalTasks('correctionOfData');
})
});
});
</script>
please noted in above error, %22 added in query string, I doubted may be that will cause this error. I don't know how to remove %22
you can find the full source code here