acf-to-rest-api icon indicating copy to clipboard operation
acf-to-rest-api copied to clipboard

Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR

Open dennisfrijlink opened this issue 4 years ago • 0 comments

At the moment I'm trying to make a POST request to a custom field in Wordpress (see code below). But whatever I try the browser stays giving the error: Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR. The weird part of the story is that making the POST request in Postman works! I tried to edit the .htaccess file with adding the rule Header set Access-Control-Allow-Origin "*" but that also didn't work. Hopefully someone can help me.

Code:

$( "#confirmButton" ).click(function() {
    var form = new FormData();
    form.append("fields[email]", "[email protected]");

    var settings = {
        "url": "https://domainname.com/wordpress/wp-json/wp/v2/blogs",
        "method": "POST",
        "timeout": 0,
        "headers": {
            "Authorization": "Bearer <my-token>"
        },
        "processData": false,
        "mimeType": "multipart/form-data",
        "contentType": false,
        "data": form
    };

    $.ajax(settings).done(function (response) {
        console.log(response);
    });
});

dennisfrijlink avatar Jan 19 '21 21:01 dennisfrijlink