hello,
I am trying to call Workflow Web service from Forms javascript, the calling went successfully from Internet Explorer but fails from Chrome and Firefox with the below error:
Access to XMLHttpRequest at 'http://10.121.3.5/Workflow/api/instances?WorkflowName=SendConfirmationSMS' from origin 'http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
jquerymin?v=NNvRrt_4VTUxpB0IOMoCb0a7YmcdZ5YTm3OVRV8yIMU1:1 POST http://10.121.3.5/Workflow/api/instances?WorkflowName=SendConfirmationSMS net::ERR_FAILED
send @ jquerymin?v=NNvRrt_4VTUxpB0IOMoCb0a7YmcdZ5YTm3OVRV8yIMU1:1
ajax @ jquerymin?v=NNvRrt_4VTUxpB0IOMoCb0a7YmcdZ5YTm3OVRV8yIMU1:1
(anonymous) @ 0:198
dispatch @ jquerymin?v=NNvRrt_4VTUxpB0IOMoCb0a7YmcdZ5YTm3OVRV8yIMU1:1
a.handle @ jquerymin?v=NNvRrt_4VTUxpB0IOMoCb0a7YmcdZ5YTm3OVRV8yIMU1:1
here is my javascript code:
$(".SendEmailbtn").click(function(){
var datarequest2= '{\
"StartingEntry":{\
"EntryGUID":"11111111-1111-1111-1111-111111111111",\
"EntryId":0,\
"FullPath":"String content",\
"Repository":"Test",\
"Server":"String content"\
},\
"WorkflowName":"SendConfirmationSMS",\
"ParameterCollection":[{\
"IsDebug":true,\
"Name":"Email1",\
"Value":"' + $('#q252 input').val() + '"\
},\
{"Name":"Language",\
"Value":"' + $('#q16 select').val() + '"\
},\
{"Name":"Email2",\
"Value":"' + $('#q262 input').val() + '"\
},\
{"Name":"Mobile",\
"Value":"' + $('#q216 input').val() + '"\
},\
{"Name":"NationalNumber",\
"Value":"' + $('#q53 input').val() + '"\
}],\
}';
$.ajax({
type: "POST",
url:"http://10.121.2.5/Workflow/api/instances?WorkflowName=SendConfirmationSMS",
data: datarequest2,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function processSuccess(data, status, req) {
var result = req.responseText;
// alert(req.responseText + " " + status);
alert("Message Sent");
},
failure: function (response) {
// alert("failed" + response.d);
alert("Failed to Send Message");
}
});
Note: I already added the below in the workflow web server web config file
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
</customHeaders>
</httpProtocol>
</system.webServer>
any help is appreciated.
Thanks,