How to pass these parameter into POST method using Volley library.
API link: http://api.wego.com/flights/api/k/2/searches?api_key=12345&ts_code=123
Screenshot of JSON structure
I tried this but again facing error.
StringEntity params= new StringEntity ("{\"trip\":\"[\"{\"departure_code\":\","
+departure,"arrival_code\":\"+"+arrival+","+"outbound_date\":\","
+outbound,"inbound_date\":\","+inbound+"}\"]\"}");
request.addHeader("content-type", "application/json");
request.addHeader("Accept","application/json");
Please visit here for the details of API.
Usual way is to use a
HashMap
with Key-value pair as request parameters with VolleySimilar to the below example, you need to customize for your specific requirement.
Option 1:
Option 2:
Directly using JSON in request body
this is an example uses
StringRequest