Closed leggetter closed 7 years ago
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
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?
Steps to reproduce
undefined
outputExpected behavior
An appropriate error should be shown explaining why the command failed.