I am trying to post an object using Guzzle laravel which I pass it using form submit from my view but when I do it says INVALID FORMAT Json Cannot Be Parsed
My View
<form method="POST" action="comparePrices">
@csrf
<input type="text" name="datas" id="textsss"/>
<input type="submit" value="save"/>
</form>
But when I post it via postman it works fine
My Controller
public function comparePrices(Request $request)
{
$token = DB::table('a_p_is_tokens')->select('*')->limit(1)->orderBy('id', 'desc')->get()->pluck('token')[0];
$client = new Client();
try {
$res = $client->post('https://test.api.amadeus.com/v1/shopping/flight-offers/pricing', [
'headers' => [
'Content-Type' => 'application/json', 'Accept' => 'application/json', 'Authorization' => 'Bearer ' . $token,
],
'form_params' => [
"data"=>[
"type" => "flight-offers-pricing",
"flightOffers" => $request->datas,
],
// 'body' => array('data'=>$items),
]);
$res = json_decode($res->getBody()->getContents(), true);
$response = $res->getResponse();
print_r(json_decode($response->getBody(), true));
// return view('agents.agentsTickets');
} catch (RequestException $e) {
$response = $e->getResponse();
$result = json_decode($response->getBody()->getContents());
return response()->json(['data' => $result]);
// return [json_decode($request->datas)];
}
dd([$items]);
return view('agents.agentsTickets');
}
Error Code
{
"data": {
"errors": [
{
"code": 477,
"title": "INVALID FORMAT",
"detail": "JSON cannot be parsed",
"status": 400
}
]
}
}