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

API calls fail when payload contains values with ampersands in them #8

Closed
anttiviljami opened this issue May 29, 2018 · 3 comments
Closed
Assignees

Comments

@anttiviljami
Copy link
Contributor

Whenever I try to send any payload with a value with the letter "&" in it, I always get a 401 error saying my oauth signature is incorrect.

Error: Request failed with status code 401                                                                                                          
    at createError (/Users/akuo/bynder-js-sdk/node_modules/axios/lib/core/createError.js:16:15)                                                                                                                          
    at settle (/Users/akuo/bynder-js-sdk/node_modules/axios/lib/core/settle.js:18:12)                                                                                                                                    
    at IncomingMessage.handleStreamEnd (/Users/akuo/bynder-js-sdk/node_modules/axios/lib/adapters/http.js:201:11)                                                                                                        
    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:80:11)                                                                                                                                                       
    at process._tickCallback (internal/process/next_tick.js:104:9)                                                                                                                                                       message=Invalid signature, 
signatureBaseString=..., statuscode=401                        
@anttiviljami
Copy link
Contributor Author

Looks like the problem is that ampersands don't get encoded in the payload. The fix is using encodeURIComponent, instead of encodeURI when generating the query string.

@GuilhermeSCP
Copy link
Contributor

Do you want to create a PR for this repo as well?

@anttiviljami
Copy link
Contributor Author

I already did? #9

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