I want to send a post request to an external api using guzzle , but i get this error :
Client error: POST https://api.platform.ly/ resulted in a 404 Not Found response:
{"status":"error","message":"Missing Parameters"}
$client = new \GuzzleHttp\Client();
$url = "https://api.platform.ly/";
$body['api_key'] = ENV('PLATFORMLY_KEY');
$body['action'] = 'add_contact';
$body['value'] = [
'project_id' => '1589',
'email' => $user->email,
'name' => $user->name
];
$request = $client->post($url, ['form_params'=>$body]);
dd($request);
$response = $request->send();
dd($response);
This should fix your problem. A JSON string is needed on the
valuefield per platformly docs, so utilizejson_encodelike so.I had the same issue and it took a min to figure it out because it wasn't clear.
Here is your code snippet with json_encode implemented.