SSL Authentication

0

I am facing a small problem with an api, whenever I send the request I get the following errors:

jquery-3.3.1.min.js: 2 Failed to load link : Response to preflight request does not pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access. send @ jquery-3.3.1.min.js: 2 ajax @ jquery-3.3.1.min.js: 2 (anonymous) @ (index): 14 (index): 1 Failed to load link : No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access. The response had HTTP status code 401.

I'm using this code to access:

<!doctype html>
  <html>
          <header>

          </header>
          <head>
                    <script src="jquery-3.3.1.min.js"></script>

                  <script type="text/javascript">



                                   $.ajax
                                            ({
                                            type: "POST",
                                            url: "https://api.iugu.com/v1/invoices",
                                            dataType: 'json',
                                            crossDomain: true,
                                            async: false,
                                            headers: {
                                            "Authorization": "Basic " + btoa("xxxxxxxxxxxxxxxxxxxxxxxxxxxx" + ":"),
                                            "Access-Control-Allow-Origin":"*",
                                            "Access-Control-Allow-Methods": "HEAD, GET, POST, PUT, PATCH, DELETE",
                                            "Access-Control-Allow-Headers":"Origin, Content-Type, X-Auth-Token"
                                            },
                                            data: '{ "comment" }',
                                            success: function (){
                                            alert('Thanks for your comment!'); 
                                            }
                                            });


                                    var data = JSON.stringify({
                                    "email": "[email protected]",
                                    "due_date": "2018-10-08",
                                    "items": [
                                    {
                                    "description": "carro",
                                    "quantity": 1,
                                    "price_cents": 1500000
                                    }
                                    ],
                                    "payer": {
                                    "cpf_cnpj": "xxxxxxxxxxx",
                                    "phone_prefix": "31",
                                    "phone": "xxxxxxxx",
                                    "address": {
                                    "zip_code": "3xxxxxxx",
                                    "number": "109"
                                    }
                                    }
                                    });

                                    var xhr = new XMLHttpRequest();
                                    xhr.withCredentials = true;

                                    xhr.addEventListener("readystatechange", function () {
                                    if (this.readyState === this.DONE) {
                                    console.log(this.responseText);
                                    }
                                    });

                                    xhr.open("POST", "https://api.iugu.com/v1/invoices");

                                    xhr.send(data);

                  </script>
          </head>
          <body>

          </body>
  </html>

Cv with some company colleagues said it may be due to SSL, does anyone know how to disable it?

    
asked by anonymous 01.10.2018 / 22:06

0 answers