Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attachments returning a 401 signature_invalid error #14

Closed
tommaitland opened this issue Apr 24, 2017 · 3 comments
Closed

Attachments returning a 401 signature_invalid error #14

tommaitland opened this issue Apr 24, 2017 · 3 comments
Assignees

Comments

@tommaitland
Copy link

tommaitland commented Apr 24, 2017

I'm trying to use the attachment endpoints which are in this wrapper, and I'm posting this with the understanding they're not properly supported yet – but thought someone might be able to help.

I can't seem to get around this error:

I've read the code and am posting like this:

      let stats = fs.statSync(`/tmp/myfile.pdf`);

       // upload the attachment
        let attachment = xeroClient.core.attachments.newAttachment({
            MimeType: 'application/pdf',
            FileName: `myfile.pdf`,
            ContentLength: stats.size
        })

        return attachment.save(`/Invoices/${invoice.response.Id}`, `/tmp/myfile.pdf`)

The return is consistently this:

{ Error: POST call failed with: 401
    at /user_code/node_modules/xero-node/lib/application.js:129:42
    at passBackControl (/user_code/node_modules/xero-node/lib/oauth/oauth.js:400:25)
    at IncomingMessage.<anonymous> (/user_code/node_modules/xero-node/lib/oauth/oauth.js:416:17)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
  data: 
   { oauth_problem: 'signature_invalid',
     oauth_problem_advice: 'Failed to validate signature' } }

I've tried the endpoint using another wrapper (npm/xero) and I'm getting the same error, I'm wondering if neither support signing for attachments – or am I doing something wrong?

@tommaitland tommaitland changed the title Translations returning a 401 signature_invalid error Attachments returning a 401 signature_invalid error Apr 26, 2017
@jordanwalsh23
Copy link
Contributor

Hi @tommaitland .

I've just fixed this in the latest version 2.1.0. Please update your dependencies and your code should start working.

You can find an example of how to use attachments in the Github Docs here

Please close this issue if it meets your requirements, or update if you're still having problems.

Thanks

Jordan

@jordanwalsh23
Copy link
Contributor

Closing this off as it's now a supported feature. Please raise another issue if needed.

Thx!

@tommaitland
Copy link
Author

Thanks @jordanwalsh23 – just confirming this is all working for me now, and appreciate the documentation + help!

philals pushed a commit that referenced this issue Mar 14, 2018
use provide oauthlib factory for pdfs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants