AnsweredAssumed Answered

CORS error when calling POST

Question asked by x0262352261604 on Jul 28, 2017
Latest reply on Sep 4, 2017 by Sjaak Overgaauw

I could not find the answer to this question

 

I am trying to call a POST service from AJAX request which is cross platform and I am getting the below error failing in OPTIONS

XMLHttpRequest cannot load https://myboomi.abc.com/ws/rest/abel/authorization/pages/1/users;boomi_auth=token_value. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3010' is therefore not allowed access. The response had HTTP status code 403.

This is working fine with POSTMAN.

 

Following are the setup which is done on CORS at Boomi shared web server.

Domain - localhost
Cache Timeout - -1
Options

Checked Allow Credentials
Checked HTTP Request Handling
Checked HTTPS Request Handling
Port

3000
3011
8000
3002
3010
Method

DELETE
POST
OPTIONS
GET
PUT
Allowed Request Header

Access-Control-Allow-Methods:HEAD,GET,POST,OPTIONS
Access-Control-Allow-Origin:*
Origin:*
Access-Control-Request-Headers:origin,x-requested-with,Content-Type,accept,authorization

Exposed Response Header

Access-Control-Allow-Methods:HEAD,GET,POST,PUT,OPTIONS,DELETE
Access-Control-Allow-Credentials:true
Access-Control-Request-Headers:origin,x-requested-with,cache-control,content-type,expires,last-modified,accept,content-language,authorization,pragma
Access-Control-Max-Age:1728000
Access-Control-Allow-Origin:*

 

 

 

Here is the client call

head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

 

<script>

   

    $(document).ready(function(){

        $("#postButton").click(function() {

            $.ajax({

                type:"POST",

                url: "https://myboomi.abc.com/ws/rest/abel/authorization/pages/1/users;boomi_auth=token_value",

                data: {a : 'abc', b: 'abc' },

               crossDomain: true,

                beforeSend: function(xhr){

                    xhr.setRequestHeader('Access-Control-Allow-origin', 'true');

                },

                dataType: 'json'

            });

        });

    });

 

</script>

 

</head>

<html>

    <h1>Testing POST</h1>

 

    <button id='postButton'>POST</button>

</html>

 

Please let me know what needs to be done to fix this issue.

Outcomes