Lakele

Guzzel POST issue

Posted 1 month ago by Lakele

Hello Guys ,

I would like to thank everyone here for giving help !

I faced an issue these days with guzzel , I'am suign version 6.0

my issue is :

400 Bad Request 
["Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.List`1[Va (truncated.

This is my function :

public function store(Request $request)
    {

        $client = new Client(['headers' => ['Content-Type' => 'application/json']]);
        $response = $client->post('url', ['body' =>json_encode(['email' => '[email protected]' , 
                 'password' => 1234' ,
                 'confirmPassword' => '1234' ,
                 'firstName' => 'john' ,
                 'lastName' => 'doe' ,
                 'products' => ['dfgdfg'],
                 'roles' => [
                    'name' =>  'Customer',
                    'productId' =>  'dfgdfg',
                ]]) 
                ]);

    }

I'am sending this json :

{
   "email" : "[email protected]",
   "password" : "1234",
   "confirmPassword" : "1234",
   "firstName": "john",
   "lastName": "doe",
   "products": ["dfgdfg"] , 
   "roles": [
       {
           "name": "Customer",
           "productId": "dfgdfg"
       }
   ]
}

I tested with Insomnia , it's workign fine , but when I implemented this function , it's giving me this error ?

any Idea ?

Thank you

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.