Search code examples
javarestapihttpovh

OVH JAVA API using Get request with parameters


am trying to create a web interface to interact with OVH's telephony API ovh telephony api using the official JAVA wrapper OVH java wrapper.

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 signature.

Could someone help me with this ?


Solution

  • The API of the java wrapper specifies that the api.get method receives as the second parameter (in the three parameters version of api.get) the GET body; but you are passing a string containing the URL parameters:

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

    Since the request you need does not require a body and does require the parameters in the URL, you need to use the following invocation:

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

    Pay attention that {ACCT} and {NUM} must be replaced by the actual account and service number values in that first string. Also, notice the parameters are appended directly into the string URL.

    Hope this helps.