ajaxaxioscorswufoo

Axios and Wufoo: 'Request header field authorization is not allowed' when posting from React


It's a problem that I've spent hours combing through similar questions here on StackOverflow, but can't seem to find a definitive answer to.

The details are:

Here's my code, I'm clearly setting up the authentication side of things incorrectly, but cannot for the life of me work out what the issue is.

Does anybody have any ideas?

    const wufooSubdomain = 'imgforms';
    const formId = 'abcdefg';
    const formAuth = `Basic xxxxxxxxxxxxxxxx==`;
    const postURL = `https://${wufooSubdomain}.wufoo.com/api/v3/forms/${formId}/entries.json`;

    axios({
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        Authorization: formAuth,
      },
      method: 'post',
      url: postURL,
      data: formData,
    }).then((result) => {
      console.warn('1) result is ', result);
    });

Solution

  • As @sideshowbarker correctly pointed out, the Wufoo docs don't demonstrate using the front-end to access their API at all. Sadly their response to my support ticket was:

    "We don't support the API because it is advanced"

    However, following the documentation and changing tact slightly I was able to implement a middle-tier in Node to handle the AJAX request.