2

I am trying to adapt this curl request to run in Axios but I keep getting an error "Header Validation Failure". What is wrong with my authentication?

Original Curl:

curl -X POST www.website.com
  -H "Content-Type: application/json" 
  -u 'XXX:YYY' 
  -d $'{
     datastring
  }'

Axios:

axios({
      method: 'post',
      url: 'www.website.com',
      data: dataString,
      headers: {
            'Content-Type': 'application/json',
            'Authorization': \`Basic 'XXX:YYY'`
        }
    }).then((response) => {
      alert(response);
    });
RedGiant14
  • 21
  • 2
  • Is the $ after -d a typo, or is that your actual command? Also, your codeblock is formatted with newlines, are you escaping the newlines with a backslash when you actually run the command? Compare to the code block in this answer: https://stackoverflow.com/a/7173011/7586861 – jarcobi889 Aug 20 '20 at 21:42

0 Answers0