I want to send request with Http facade in Laravel but i can't pass json object data it must be just array.
Http::withHeaders(['Content-Type' => 'application/json'])->withOptions(['headers' => $coockie])->post($this->policy_url . $address, json_encode($data));
My data variable value:
$data = [
"document" => [
"customerId" => 1,
"currencyId" => 1,
"settlementPolicyId" => 8,
"storeId" => 16,
"documentPatternId" => 2,
"items" => [
[
"productId" => 193,
"unitId" => 2,
"quantity" => 1,
"storeId" => 16,
"TrackingFactor1" => "1214",
"PartTrackingFactorRef1" => 1053,
"TrackingFactorHasQuantity1" => true,
"TrackingFactorValue" => "test",
"fee" => 0
]
]
],
"payments" => [
[
"key" => "Cash",
"amount" => 445810,
"attr" => []
]
]
];
The error:
TypeError Argument 2 passed to Illuminate\Http\Client\PendingRequest::post() must be of the type array, string given