-
How do i pass 2 or more variables in a URL
about 9 years ago
-
over 6 years ago
domain_name/method_name?parameter1_name=value1¶meter2_name=value2 -
-
over 7 years ago
Uri.Builder builder = new Uri.Builder(); builder.scheme("https") .authority("abc.com") .appendPath("xyz") .appendQueryParameter("Variable1", var1) .appendQueryParameter("Variable2", var2); String url = builder.build().toString();
-
-
about 9 years ago
Hey ,
If you are making get request you can just append to the url itself with & for example
- MYURL.apiUrl+"api/v1/resolvedcommand?q="+ Uri.encode(command)+"&apiKey="+ MYURLBUILDER.apiKey;
in above example command is the value which is being passed as a parameter.
-
-
about 9 years ago
Yes you can post variables in volley api like this.
you have to create HashMap that will contain key value pair for each variable
HashMap<String, String> params = new HashMap<String, String>(); params.put("key3", "value"); params.put("key4", "value"); JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(params), new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Log.e("Response:%n %s", response.toString()); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("Error: ", error.getMessage()); } });
Hope this will help you.
-
4 Answer(s)