Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 Bad Request #31

Open
mohdaftab opened this issue Feb 15, 2018 · 8 comments
Open

400 Bad Request #31

mohdaftab opened this issue Feb 15, 2018 · 8 comments

Comments

@mohdaftab
Copy link

mohdaftab commented Feb 15, 2018

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
Copy link

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
Copy link
Author

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
Copy link

@gurjanjua's solution worked for me.

@animaldna
Copy link

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

@amandasaffer
Copy link

@gurjanjua solution worked. What gives?

@calebl
Copy link

calebl commented Jun 4, 2018

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
Copy link

@calebl THANK YOU! This worked for me

@deepak475121
Copy link

@calebl It's work for me Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants