vonage-node-sdk
vonage-node-sdk copied to clipboard
Request fails with stack trace what should not be
request
{"to":[{"type":"phone","number":"44115XXXXXX"}],"from":{"type":"phone","number":"442039XXXXX"},"answer_url":["https://google.com"]}
body:
{
"type": 400,
"title": "Bad Request",
"invalid_parameters": [
{
"reason": "Unexpected end-of-input: expected close marker for Array (start marker at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 114])\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 343]",
"name": "answer_url"
}
]
}
call:
nexmo.calls.create(request, console.log)
The problem: JSON parsing error in the backend, the "to" phone number contained invisible control characters. The browser's JSON.parse parsed successfully.
It looks like the request is valid. I'm assuming you're not actually using google.com for the answer_url. Can I see the NCCO you're using in your answer_url?
I have loaded phone numbers from a JSON and tried to make the call with those phone numbers.
Actually, the problem wasn't related to the URL. The phone number contained special characters.
So this is a bug in the nexmo backend's JSON parser. The phone number was a valid string and the node client library produced a valid JSON but the backend wasn't able to parse it because the phone number contained special characters.
This is kind of serious issue because it's very hard to debug on the client's side why the backend can't parse the request. (The node client lib sends a valid JSON)
What were the special characters in the phone number?
Closing due to inactivity