airesvsg / acf-to-rest-api

Exposes Advanced Custom Fields Endpoints in the WordPress REST API
https://wordpress.org/plugins/acf-to-rest-api/
1.33k stars 110 forks source link

Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR #367

Open dennisfrijlink opened 3 years ago

dennisfrijlink commented 3 years ago

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]", "randomemail@hotmail.com");

    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);
    });
});