MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
946 stars 278 forks source link

customCollections not working #109

Closed TheGame2500 closed 7 years ago

TheGame2500 commented 7 years ago

When I try to do

shopifyAPI.customCollection.get({ product_id : product_id })

it throws

TypeError: Request path contains unescaped characters.

I've also tried

shopifyAPI.customCollection.get({ id : collection_id}) 

as a sort of workaround, but for that it says 404 not found and shows host as undefined , even though the path looks ok.

[HTTPError: Response code 404 (Not Found)]
  message: 'Response code 404 (Not Found)',
  host: undefined,
  hostname: 'micro-clone.myshopify.com',
  method: 'GET',
  path: '/admin/custom_collections/358753670.json',
  statusCode: 404,
  statusMessage: 'Not Found' }
lpinca commented 7 years ago

The method signature is:

shopify.customCollection.get(id[, params])

you should pass only the id if you don't want to specify what fields should be included in the response.

shopify.customCollection.get(358753670)
  .then(collection => console.log(collection))
  .catch(err => console.error(err));

should work.

TheGame2500 commented 7 years ago

@lpinca same not found error

What I'm interested in is documented @ https://help.shopify.com/api/reference/customcollection

GET /admin/custom_collections.json?product_id=632910392

I'm also OK with finding the product's collects and by product id (which works) and then find each collect's custom collections (this sounds weird)

GET /admin/custom_collections/#{id}.json

Neither of those works with this package unfortunately :(

lpinca commented 7 years ago

That's weird, unfortunately I don't have a shop to check where the error is atm. Can you log the url argument here https://github.com/MONEI/Shopify-api-node/blob/a710aaa5852f3a5f41fa84cba4edb8800b9b9873/index.js#L81 and see if it is correct?

If so, try to make the same request with curl or postman and see if you still get a 404 error.

Stupid question: does the collection you are requesting exist?

TheGame2500 commented 7 years ago

@lpinca the collection does exist, just checked manually. The url argument is an object in the format :

{ path: '/admin/custom_collections/12498982.json?limit=1',
  auth: false,
  hostname: 'blabla.myshopify.com',
  protocol: 'https:' }

Should I manually build it?

lpinca commented 7 years ago

@TheGame2500 yes.

Try

curl -i -H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: <your_token_here>" \
https://blabla.myshopify.com/admin/custom_collections/12498982.json?limit=1
TheGame2500 commented 7 years ago

@lpinca turns out it still says not found. Hold on, maybe it's a mistunderstanding on my part.

TheGame2500 commented 7 years ago

@lpinca so it seems like their API has suffered an undocumented change.It works with

/admin/collections/1298479879.json

instead of

/admin/custom_collections/1298479879.json

And that's why programmers die younger.

LE: I tried editing it in custom-collection.js but it still says not found.

TheGame2500 commented 7 years ago

@lpinca when I do a call to /admin/custom_collections.json it returns an empty array. Perhaps the fault's with me after all

lpinca commented 7 years ago

Hmm still weird, there isn't a Collection resource so I'm not sure why /admin/collections/ works.

lpinca commented 7 years ago

It looks like that is a private API.

Given that you get an empty array from /admin/custom_collections.json (this explains why you get a 404 when using a specific id) I guess that your 1298479879 collection is smart collection?

What you get if you query the smart collections? Is the array still empty?

TheGame2500 commented 7 years ago

My fault after all. There was no customCollection, it was a smartCollection but I was unfamilliar with their data format.

2016-12-14 18:56 GMT+02:00 Luigi Pinca notifications@github.com:

It looks like that is a private https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/get-both-custom-smart-collections-in-a-single-api-call-201612 API.

Given that you get an empty array from /admin/custom_collections.json (this explains why you get a 404 when using a specific id) I guess that your 1298479879 collection is smart collection?

What you get if query the start collections? Is the array still empty?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MONEI/Shopify-api-node/issues/109#issuecomment-267089285, or mute the thread https://github.com/notifications/unsubscribe-auth/AMVCo1gi2H1NIxhxt1zIPkmlOnmlwQX8ks5rIB-xgaJpZM4LL4H0 .

lpinca commented 7 years ago

No problem. Closing this, please comment or reopen if needed.