how post data array in link
data post:
{
"text": "shandiz",
"location": {
"type": "Point",
"coordinates": [
1,1
]
}
}
step 1
i coding posting:
let pData = new FormData();
pData.append('text','shandiz');
pData.append('location["type"]','Point');
pData.append('location["coordinates"]','[1,1]');
return this.http.post('https://map.ir/search?',pData);
but error 400 (Bad Request)
step 2
and send curl for testing
<?php
curlPost('https://map.ir/search', [
'text' => 'shandiz',
'location["type"]' =>'Point',
'location["coordinates"]'=>'[1,1]',
]);
function curlPost($url, $data) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);// برای خطای https
curl_setopt($ch, CURLOPT_HTTPHEADER, array('api-key:42b0dfbdc6174fea96e552e8097fb52f'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
if (curl_error($ch)) {
throw new \Exception(curl_error($ch));
}
curl_close($ch);
// return $response;
var_dump($response);
}
?>
but curl error
how to post data array in step 1 , step 2?
thanks