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

Using nexmo number:buy with an account in trial mode shows undefined output #104

Closed
leggetter opened this issue Oct 23, 2016 · 2 comments · Fixed by #105
Closed

Using nexmo number:buy with an account in trial mode shows undefined output #104

leggetter opened this issue Oct 23, 2016 · 2 comments · Fixed by #105

Comments

@leggetter
Copy link
Contributor

Steps to reproduce

  1. Sign up for a new account
  2. Set up the CLI to use the account API Key and API Secret
  3. Try to buy a number
  4. See undefined output

Expected behavior

An appropriate error should be shown explaining why the command failed.

@cbetta
Copy link
Contributor

cbetta commented Oct 23, 2016

FYI this is what happens:

info: Request: { host: 'rest.nexmo.com',
  port: 443,
  path: '/number/buy?country=GB&msisdn=447520618997&api_key=6159f78b&api_secret=784a14a6ac71a278',
  method: 'POST',
  headers: 
   { 'Content-Type': 'application/x-www-form-urlencoded',
     Accept: 'application/json',
     'User-Agent': 'nexmo-node/1.1.0-beta1/v6.7.0' } } 
Body: undefined
info: response ended: 401
Validator.response() - Error: 
{ 'error-code': '401',
  'error-code-label': 'authentication failed' }
Validator.response() - Response: 
{ 'error-code': '401',
  'error-code-label': 'authentication failed' }
End Validator.response()
undefined

I need to see why that error message is not bubbling up

@cbetta
Copy link
Contributor

cbetta commented Oct 23, 2016

We figured out that the reason for this happening is that the Node library has some inconsistencies in when it returns the error in the error callback vs the response callback. In this case we are receiving an error with an error-code-label instead of a message.

I've opened ticket nexmo/nexmo-node#78 to see if we can improve this.

Additionally the API not giving us anything to work with either. The authentication here was successful but the user was not authorized to buy numbers yet (see trial mode account). I suggest we improve the API to return a 403 (Forbidden) instead of a 401 (Unauthorized) and possibly provide some better messaging with the response to provide some idea as to why this action was forbidden.

@tjlytle did any of this end up in the API spec yet?

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

Successfully merging a pull request may close this issue.

2 participants