I came across a problem recently when I tried to pass multiple data's
The problem:
The API use POST to send parameters One of the parameter is designed to be able to accept multiple values with the same name/key. In GET it could be represented as such : /api?name=James&name=Peter&name=Richard&… In this example, we are sending 3 values for “name” (James, Peter and Richard), and this is perfectly valid since the API is expecting it and will process the value as it should. The problem now lies with POST. In PHP cURL, a POST parameter is sent like this:
$data = array("name" => "James", "email" => "james@someone.com");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
Now we all know in an array, we only set the key once. Thus there is no way to send 3 different value for “name” in this case. So, how are we suppose to send ?name=James&name=Peter&name=Richard by POST, but not by PHP this time but in HTTP curl format?
So how do I go sending multiple data in HTTP post something like this
{
"funcrr":"create_insert_new_delivery",
"data":{
"name":"James",
"email":"james@someone.com",
//MORE OF LIKE AN ARRAY BUT IN HTTP FORM
"product_name":"Pear",
"product_weight":"30",
"product_name":"Rice",
"product_weight":"60",
"product_name":"Yoghury",
"product_weight":"100",
}
}