laravel-shopify icon indicating copy to clipboard operation
laravel-shopify copied to clipboard

rest api

Open unplugged216 opened this issue 2 years ago • 6 comments

For bug reporting only! If you're posting a feature request or discussion, please ignore.

Expected Behavior

When following the documented method for querying customer information in a shop, I am expecting to get a single result back.

$req = $shop->api()->rest('GET','/admin/api/customers/search.json', ['query' => 'email:[email protected]'])['body'];

Current Behavior

When running the above query, it is as if the query is not actually run and instead all results are returned. I have confirmed a single customer exists with that email. Yet it returns 50 results not just the single customer.

Failure Information

N/A

Steps to Reproduce

Run the above query using an email you know exists

unplugged216 avatar Oct 07 '22 22:10 unplugged216

Well, after firmly planting my face into the keyboard, repeatedly, I determined the issue. An undocumented thingy....

In the Shopify dev docs and here in the wiki, it only assumes a customer search needs one query parameter. Well, thats false it appears. You must include 'limit' of 1.... I am working to confirm this but so far thats what it seems.

unplugged216 avatar Oct 08 '22 15:10 unplugged216

Glad you found the solution @unplugged216 - I'm going to close this ticket now.

Kyon147 avatar Oct 11 '22 07:10 Kyon147

hey @unplugged216 how you resolved this? as per your conversation i added a limit but still getting all records

pramod-praella avatar Oct 12 '22 14:10 pramod-praella

hey @unplugged216 how you resolved this? as per your conversation i added a limit but still getting all records

Hey @Pramod-HulkApps!

Here is an example, demonstrating what did not work and what worked for me.

What did not work $shop->api()->rest('GET','/admin/api/2022-10/products.json', [ 'product_type' => 'Demo Type'])['body'];

This seemed to fix my issue $shop->api()->rest('GET','/admin/api/2022-10/products.json', ['limit' => '250', 'product_type' => 'Demo Type'])['body'];

Please not I am also using the latest API. I opted in this call to set the API version manually instead of in ENV as I have noticed the ENV vars are not getting loaded consistently by the package.

unplugged216 avatar Oct 12 '22 17:10 unplugged216

Glad you found the solution @unplugged216 - I'm going to close this ticket now.

@Kyon147 ,

I would recommend not closing this as my solution may only work for me. This is a documentation issue in this package. The package provides a wiki demonstration that does not work.... Closing an issue without resolve is unsettling for the project I feel.

unplugged216 avatar Oct 12 '22 17:10 unplugged216

Hi @unplugged216

Happy to reopen, that's my misunderstanding reading it as a API issue rather than a package one. I tried a direct api call, and don't see any issues - so there could be a bug in the shopify-basic-api package but would need some more investigation.

Kyon147 avatar Oct 13 '22 08:10 Kyon147