Remco1337
Remco1337

Reputation: 21

Laravel Shopify API returns Required parameter missing or invalid on POST Request

I am using Osiset's github for laravel + shopify: https://github.com/osiset/laravel-shopify

But I don't seem the get the POST request going, tried all kinds of variantions already hope one of you'll see my mistake!

Code:

$order_array = [
    'order' => [
        'email' => "[email protected]",
        'line_items' => [
             'variant_id' => 6103067132088,
             'quantity' => 1
        ]
    ]
];

$order_array = json_encode($order_array);
$shop = User::first();
$request = $shop->api()->rest('POST', '/admin/orders.json', ['body' => $order_array]);

dd($request['body']);

if I do a dd() on order_array after the encode it shows:

{"order":{"email":"[email protected]","line_items":{"variant_id":6103067132088,"quantity":1}}}

And then it returns

array:1 [
"order" => "Required parameter missing or invalid"
]

I've also tried to make 'body' to 'query'...

Upvotes: 0

Views: 1734

Answers (1)

Remco1337
Remco1337

Reputation: 21

I finally found the solution!

// Replace rest

$request = $shop->api()->rest('POST', '/admin/orders.json', ['body' => $order_array]);

// With request

$request = $shop->api()->request('POST', '/admin/orders.json', $order_array);

Upvotes: 1

Related Questions