Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get call with parameters doesn't work and returns 400 bad parameters #6

Open
aragoubi opened this issue May 16, 2019 · 1 comment
Open

Comments

@aragoubi
Copy link

I am trying to use a GET endpoint with parameters. this is the endpoint:

GET /telephony/{billingAccount}/line/{serviceName}/statistics

Parameters:
timeframe: string;
type : string

This is how I am doing the call:

api.get("/telephony/{myBuildingAccount}/line/{myServiceNumber}/statistics", "timeframe=daily&type=maxDelay", true);

But I am getting an error 400 bad parameters.

@oliviermorpa
Copy link

your server where you execute the code doesnt have good time (1 minute difference).
you need to compute the good time to set in header siganture:
private static final String AUTH_TIME = "/auth/time";
String endpoint="https://eu.api.ovh.com/1.0"; //tochange
private long timeDelta()
{
try {
Scanner sc = new Scanner(new URL(endpoint + AUTH_TIME).openStream());
long serverTime = sc.nextLong();
sc.close();

        long currentTime = new Timestamp(new Date().getTime()/1000).getTime();

        return currentTime - serverTime;
    } catch (Exception e) {
        throw new RuntimeException("Can't compute time drift for " + endpoint, e);
    }
}
private long getTimeSignature() {
    return new Timestamp(new Date().getTime()/1000).getTime() - timeDelta();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants