joshrps / laravel-shopify-API-wrapper

Interface designed for Shopify apps created with Laravel
MIT License
94 stars 48 forks source link

400 Bad Request #31

Open mohdaftab opened 6 years ago

mohdaftab commented 6 years ago

Hello, I am getting this error when I try to use call function. ERROR #22: The requested URL returned error: 400 Bad Request

$sh = new API;

$sh->setup(['API_KEY' => $this->api_key, 'API_SECRET' => $this->api_secret, 'SHOP_DOMAIN' => session('shop'), 'ACCESS_TOKEN' => session('access_token')]);

$call = $sh->call(['URL' => 'products.json', 'METHOD' => 'GET', 'DATA' => ['limit' => 5, 'published_status' => 'any']]);

return $call;
gurjanjua commented 6 years ago

Hi @mohdaftab , I am facing same issue whenever i am passing Data then it throwing ERROR #22 , To solve this issue i have passed parameter with URL as query parameter $call = $sh->call(['URL' => 'products.json?limit=5&published_status=any', 'METHOD' => 'GET', ]);

And it is working fine now. You can try this and if you got any other solution please also share.

mohdaftab commented 6 years ago

I have solved it by commenting out these 2 lines in the api.php file

CURLOPT_FAILONERROR => $request['FAILONERROR'], CURLOPT_VERBOSE => $request['ALLDATA'],

splitmango-jeremy commented 6 years ago

@gurjanjua's solution worked for me.

animaldna commented 6 years ago

ditto - @gurjanjua's solution was the ticket. Any idea why? This was working fine for us until now.

amandasaffer commented 6 years ago

@gurjanjua solution worked. What gives?

calebl commented 6 years ago

The problem is that Shopify has updated their server standards: https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/shopify-api-call-returns-a-http-400-error-with-html-from-google-484157

Basically, you are not allowed to pass body data with a GET request anymore. This wrapper isn't updated to handle that case yet. I was able to resolve in my code performing the call like this instead passing as 'DATA' (see commented out code).

$call = $sh->call(
    [
        'URL' => "/products.json?limit=$perPage&page=$i",
        'METHOD' => 'GET',
//      'DATA' =>
//          [
//                  'limit' => $perPage,
//              'page' => $i
//          ]
        ]);
impactcolor commented 6 years ago

@calebl THANK YOU! This worked for me

deepak475121 commented 6 years ago

@calebl It's work for me Thank You