how to access array in Post request with http client laravel

661 Views Asked by At

i have this function to store data from a blade form:

$store = Http::withHeaders([
        'Content-Type' => 'application/json',
        'Authorization' => $token,
    ])->post('http://example.com/api/Order/', [
        'Key' => 1167722,
        'No' => "12",
        'TL' => [
            'Dtl' => "",
            'Code' => "Screw Hex",
            'IsDetail' => true,
            "DTL" => [],
            ]
            ]);

            return $store;

and this is what the response return:

{"Key":1167722,"No":"12","TL":[]}

and nothing is saved inside TL array i tried wrapping TL array with json_encode() and still no luck and i tried

'TL[Dtl]' => 722,

and it didn't store as well

1

There are 1 best solutions below

0
On BEST ANSWER

SOLUTION:

'TL' => array ([
        'Dtl' => "",
        'Code' => "Screw Hex",
        'IsDetail' => true,
        "DTL" => [],
        ])
        ]);

added array()