XMLHttpRequest PUT request is blocked by CORS policy

Hello,
I’m trying to send data to my Arduino UNO. The GET method works perfectly fine, but the PUT method returns ‘has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.’ error.

This is an XMLHttpRequest in HTML.

    var request = new XMLHttpRequest();
    request.open('PUT', 'http://blynk-cloud.com/xxxxxxx/update/V0');
    request.setRequestHeader('Content-Type', 'application/json');
    request.onreadystatechange = function () {
      if (this.readyState === 4) {
        console.log('Status:', this.status);
        console.log('Headers:', this.getAllResponseHeaders());
        console.log('Body:', this.responseText);
      }
    };

    var body = [
      255,
      0,
      0
    ];

    request.send(JSON.stringify(body));

Thank you

Any reason why you don’t stick with the GET method? Is more reliable in my experience anyway.

Pete.

But I need to send 3 numbers…red, green and blue values. How can I send it with GET? In my arduino project I’m using as for example
int r = params[0].asInt();

Have you read the API documentation?

Pete.

Yes…GET method can send one value

you can send multiple values…

http://blynk-cloud.com/xxxxxxx/update/V1?value=50&value=100&value=150

Pete.

Ohhh, thank you. I don’t know about that.