The API documentation states that you need to insert a JSON string with parameters into the request body and an example is given:

curl -v -X POST -d '{"signature":"deb5b02159898a6ab6f120624fa2f72c","marker":"ВставьтеСюдаВашМаркер","host":"beta.aviasales.ru","user_ip":"127.0.0.1","locale":"ru","trip_class":"Y","passengers":{"adults":1,"children":0,"infants":0},"segments":[{"origin":"NYC","destination":"LAX","date":"2016-11-25"},{"origin":"LAX","destination":"NYC","date":"2016-12-18"}]}' -H 'Content-type:application/json' http://api.travelpayouts.com/v1/flight_search 

And how can I insert a json-array into the body of the request when using cURL in PHP?

    1 answer 1

    You need to set the CURLOPT_POST options to 1 and send your variables to CURLOPT_POSTFIELDS :

     $ch = curl_init(); $post_data = array ( "foo" => "bar", "query" => "12", "action" => "Submit" ); curl_setopt($ch, CURLOPT_URL, $URL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 

    Json can be decoded using json_decode . Data in this format does not pass (only key=value&key1=value1 or an array will do)