Http PUT volley. Parameter in the middle of the url

62 views Asked by At

I am using Volley for my HTTP requests and I have an HTTP put URL which looks like below. http://mycompany.com/favorite/{roomNumber}/count. I am using a JSON object request. How do I make the API work with the extra "/count" in the API? I am passing the parameter room number in the JSON object.

JSON Object request works fine with this type of URL "http://mycompany.com/favorite/{roomNumber}"

JSON Object request

JsonObjectRequest request = new JsonObjectRequest(METHOD_TYPE_PUT, url, jsonObjectParams, responseListener, errorListener)

Can somebody help me with passing the JSON object parameter in the middle of the URL

Thanks.

1

There are 1 answers

0
Brahma Datta On

You can call the API dynamically like this,

private void getTheApiData(int roomNumber){

  JsonObjectRequest request = new JsonObjectRequest(METHOD_TYPE_PUT, 
         "mycompany.com/favorite" + roomNumber + "/count", 
  jsonObjectParams, responseListener, errorListener)

}

and call the above API dynamically by the method when you get the new data every time like this.

getTheAPiData(20) //if room number is 20

let me know if you have any issue @Shravani