I'm trying to replicate a Curl request to download a PDF in Ajax. The Curl requests are explained in the PDF Filler docs here. The following Curl request successfully yields a response of the file content:
curl -X "GET" "https://api.pdffiller.com/v1/fillable_template/DOCUMENT_ID/download" -H "Authorization: Bearer API_KEY_FROM_STEP1"
I've tried the following Ajax:
$.ajax({
method: 'GET',
url: 'https://api.pdffiller.com/v1/fillable_template/DOCUMENT_ID',
headers: {
Authorization: 'Bearer API_KEY_FROM_STEP1',
},
})
Which yields the following error message:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I've also tried xhr for the header, which also gives the same error:
$.ajax({
method: 'GET',
url: 'https://api.pdffiller.com/v1/fillable_template/DOCUMENT_ID',
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + 'API_KEY_FROM_STEP1');
xhr.setRequestHeader('Accept-Language', 'en_US');
},
})
Any thoughts on where I'm going wrong? Thanks!