Open yulierbrainhi opened 10 months ago
Hey @yulierbrainhi - is this on all requests or some? when you get a successful request are you utilizing the same client or a different one? Do you have an example of a successful request so that I can compare?
Hello @ajrice6713, this is just for some requests. The most interesting thing is that this same request works well for me with Postman, but with Axios or the SDK from NodeJs it does not work for me.
This request works for me with the same username and password as the previous error:
This previous request gives me an error with Axios and the SDK, but it works for me with Postman:
After tracing the code I added this line and it works fine:
numbers.Client.globalOptions.apiEndPoint = "https://dashboard.bandwidth.com:443/v1.0";
Hey @yulierbrainhi - sorry for the delay as I have been on holiday
Glad that you found a workaround, my guess is there was an old API URL in there that was deprecated. I will get a ticket in to get this updated so that we ensure the client defaults to a working URL.
Thanks for raising this issue!
Hey @yulierbrainhi
Looking a bit deeper into your logs
error: Error: cannot GET /api/accounts//availableNumbers?xml2jsParserOptions%5BexplicitArray%5D=false&xml2jsParserOptions%5Basync%5D=true (401)
at Response.toError (/.../node_modules/superagent/lib/node/response.js:94:15)
at ResponseBase._setStatusProperties (/.../node_modules/superagent/lib/response-base.js:123:16)
at new Response (/.../node_modules/superagent/lib/node/response.js:41:8)
at Request._emitResponse (/.../node_modules/superagent/lib/node/index.js:752:20)
at IncomingMessage.<anonymous> (/.../node_modules/superagent/lib/node/index.js:916:38)
at IncomingMessage.emit (node:events:526:35)
at endReadableNT (node:internal/streams/readable:1589:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
status: 401,
text: '',
method: 'GET',
path: '/api/accounts//availableNumbers?xml2jsParserOptions%5BexplicitArray%5D=false&xml2jsParserOptions%5Basync%5D=true'
},
It looks like the accountId path parameter was missing in the request error: Error: cannot GET /api/accounts//availableNumbers?
, which would definitely cause a 401
I have been unable to recreate, and the v1 and port in the URL shouldn't matter - can you confirm your accountId was resolving?
Checklist
Description
In nodejs when I call some functions it throws a 401 error
Environment Information
Sample Code Snippet
Stack Trace
Expected Behavior
List of available numbers