Vonage / vonage-python-sdk

Vonage Server SDK for Python. API support for Voice, SMS, WhatsApp, Verify (2FA), Video Meetings and more.
https://developer.vonage.com
Apache License 2.0
189 stars 117 forks source link

503 responses for Number Insight with Portuguese numbers #47

Closed leggetter closed 7 years ago

leggetter commented 7 years ago

Retrieving NI for a Portuguese number returns a 503 when executing this sample code: https://github.com/nexmo-community/nexmo-python-quickstart/commit/21c02b938dfc13ffa3af53c50ea724e629538efd

However, the cURL with this number seems to work:

curl -X "POST" "https://api.nexmo.com/ni/basic/json" \
-d "api_key=KEY" \
-d "api_secret=SECRET" \
-d "number=351914XXXXXX"
{
    "status": 0,
    "status_message": "Success",
    "request_id": "SOME_REQUEST_ID",
    "international_format_number": "351914XXXXXX",
    "national_format_number": "914 XXX XXX",
    "country_code": "PT",
    "country_code_iso3": "PRT",
    "country_name": "Portugal",
    "country_prefix": "351"
}%

So right now this looks like a problem with the Nexmo Python library. I don't know why we only see this problem with the Portuguese numbers, but the same code works with a UK number.

judy2k commented 7 years ago

In the latest release of nexmo, the call get_number_insight is deprecated - it calls the old endpoint "number/lookup/json", so it isn't equivalent to the curl request above.

The modified curl request looks like this (and gets the 503):

curl -i "https://api.nexmo.com/number/lookup/json" -d "api_key=KEY" -d "api_secret=SECRET" -d "number=351914XXXXXX"
HTTP/1.1 503 Service Unavailable
Date: Mon, 17 Jul 2017 14:55:28 GMT
Server: PWS/8.2.1.6.5
X-Px: nc h0-s4009.p6-lhr ( h0-s1019.p1-iad), nc h0-s1019.p1-iad ( origin>ste)
Px-503: O socket timeout
Content-Length: 53
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive

<html><body>Not found (error to origin)</body></html>

Use get_basic_number_insight instead.

judy2k commented 7 years ago

I've just confirmed that the curl request in my comment above works for a UK number, but not for portuguese numbers, so it looks like a limitation of the deprecated service.

So the fix for this is for the user to use get_basic_number_insight. The old API won't work for this country.