get call with parameters doesn't work and returns 400 bad parameters
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.
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();
}