You are viewing limited content. For full access, please sign in.

Question

Question

calling workflow web service from Forms javascript

asked on February 22 Show version history

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,

 

1 0

Replies

replied on February 25 Show version history

Chrome and Firefox have stricter built-in CORS restrictions. If you want to disable Chrome's CORS security, there are instructions on how to do so in this StackOverflow post.

Before troubleshooting the browser issues further though, I would update your setup to use HTTPS for the Workflow Web Service and replace the localhost and IP references with the actual FQDNs. 

Edit: You are almost certainly running into the fact that Chrome does not support CORS for localhost requests. While you can disable Chrome security, you should update the localhost and IP references to address the root cause as I suggested above.

 

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.