0

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

4
  • Do you mean that TL is empty in the response or in the incoming request? Because if TL is empty in the response the problem is not yours but of the server that gives you the response. Commented Aug 5, 2022 at 14:41
  • when i try to send data from the above function using http client it doesn't store anything inside [TL] but when i send it using postman or guzzle data will be stored inside [TL] Commented Aug 5, 2022 at 14:50
  • Try with 'TL' => json_encode(['Code' => "Screw Hex",]) Commented Aug 5, 2022 at 15:13
  • i tried it before Commented Aug 5, 2022 at 15:30

1 Answer 1

0

SOLUTION:

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

added array()

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.