pdflayer API post request saying I didnt not provide api_key even though it did

I am currently trying to work with the API from http://www.pdflayer.com, however I am having issues with providing the api_key through a post request with Axios.

My code looks like this:

var config = require('./../config');
var axios = require('axios');
var fs = require('fs');

const BASE_URL = 'http://api.pdflayer.com/api/convert';

module.exports = {

    createQuotePdf() {
        var data = {
            document_url: 'https://www.apple.com',
            access_key: config.pdflayer_acccess_key,
            page_size: 'A4',
            test: '1'
         }

        axios.post(BASE_URL, data)
        .then((data) => {
            console.log(data);
            fs.writeFile('./download.pdf', data.body, function(err) {
                if (err) console.log('error: ', err);
            })
        });
    }

};

However, every time I make the request, it is saying that I did not provide the api key, even though I specified.

It would be great if someone could help me.

Best regards

1 answer

  • answered 2017-11-14 23:33 Petter Östergren

    Have you tried appending it directly to your BASE_URL since that seams to be the way they are building it

    BASE_URL = ('http://api.pdflayer.com/api/convert?access_key=', YOUR_ACCES_KEY)'