Vonage / vonage-java-sdk

Vonage Server SDK for Java. API support for SMS, Messages, Voice, Text-to-Speech, Numbers, Verify (2FA), Video and more.
https://developer.vonage.com/en/home
Apache License 2.0
95 stars 119 forks source link

404 Not Found on all api calls #143

Closed ihunzai-dev closed 5 years ago

ihunzai-dev commented 6 years ago

I am getting 404 response on all API calls for the current in-progress voice call on local machine however it works fine on azure instance located in US region.

The number I purchased is US-Based, and my local machine is in Asia. The issue is much like the one mentioned in this post

There should be some option to set API base-url in client library

cr0wst commented 6 years ago

It looks like this functionality is going to be provided with #77 as it also resolves #58.

@judy2k offered up a workaround on https://stackoverflow.com/questions/48685775/404-error-in-all-nexmo-api-calls in regards to extending the ModifyCallMethod class's makeRequest method to provide a new base url.

cr0wst commented 5 years ago

Resolved with #194 released in 3.9.0

vinokanth92 commented 5 years ago

Hey I am trying to resolve this issue by configuring the baseUrl. According this article the 2 possible API base ULIs are

  1. https://api-us-1.nexmo.com
  2. https://api-sg-1.nexmo.com

I configured them in the following way:

            HttpConfig httpConfig = new HttpConfig.Builder()
                    .apiBaseUri("https://api-sg-1.nexmo.com")
                    .build();

But I still do get 404 NOT FOUND for both the listed base URIs.

When I call Nexmo API from my local server (Sydney) everything works. But when deploy it on AWS (USA) region I do get 404. How do I resolve this?

cr0wst commented 5 years ago

Hi @vinokanth92,

I think you found a bug that I didn't account for when implementing the base uri rewriting logic. I'll try to get a patch out today to fix this.

The full URI that gets used for some of our API endpoints is https://api.nexmo.com/v1/... and I was stripping out the v1 if you weren't electing to use the default uri. Sorry about that!

Try and see if using https://api-sg-1.nexmo.com/v1 fixes it in the meantime.

Steve

vinokanth92 commented 5 years ago

Hey Steve thanks for your response. There is no need to apologise. You guys are doing a great job. As you suggested adding v1 works like a charm. Thanks a lot. Cheers.

On Wed., 31 Oct. 2018, 03:49 Steve Crow <notifications@github.com wrote:

Hi @vinokanth92 https://github.com/vinokanth92,

I think you found a bug that I didn't account for when implementing the base uri rewriting logic. I'll try to get a patch out today to fix this.

The full URI that gets used for some of our API endpoints is https://api.nexmo.com/v1/... and I was stripping out the v1 if you weren't electing to use the default uri. Sorry about that!

Try and see if using https://api-sg-1.nexmo.com/v1 fixes it in the meantime.

Steve

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Nexmo/nexmo-java/issues/143#issuecomment-434379300, or mute the thread https://github.com/notifications/unsubscribe-auth/ANCC6KCoK0ZXWn4xok1oUO6E1_ISbewVks5uqIM1gaJpZM4R-XKP .

cr0wst commented 5 years ago

Resolved in #217 released in 3.10.0. The path for versioned APIs will always be /v#/... now instead of trying to guess when it would be appropriate.

I started the release about 20 minutes ago, it can take a bit before it hits the central repositories.

vinokanth92 commented 5 years ago

@cr0wst Hello. I am currently using library version 4.01. Previously was using version 3.9.x and your solution of appending "v1" was working. But now when upgraded my library version this fix no more works. I get 404 for using both

How can I fix this?

Edit: Sorry the API is working as expected. The issue was with invalid authentication. In fact the error was kind of misleading, initially it was stating 404 for some URLs and 401 for some. Finally worked for a valid auth keys.

Thank you.