Ad

How To GET Resources From Shopify API Admin Endpoint Using Rails

- 1 answer

I'm working on a private Shopify application. I'm trying to get this resource (from Shopify endpoint):

https://store.myshopify.com/admin/products.json

using Net::HTTP library in this way:

url = 'https://'[email protected]_key+':'[email protected]+'@storename.myshopify.com/admin/products.json' 
uri = URI(url)  
response = Net::HTTP.get(uri) 
p = JSON.parse(response)

But what I get is:

=> {"errors"=>"[API] Invalid API key or access token (unrecognized login or wrong password)"}

What is the correct way to get resources from Shopify admin endpoints?

Ad

Answer

Ok, so I found the solution for my problem. For anyone who doesn't know how to access Admin Shopify API endpoints (for example: /admin/products.json?collection_id=841564295) which requires authentication, you may use 'Postman' Chrome App.

Here is the tutorial of how to use it.

Most importantly is that Postman (from its UI) generates a code for you in number of languages (including in Ruby). enter image description here So this is how you use it. Just copy-paste this code into your Rails application and don't forget to add require 'OpenSSL' coz the Postman some how doesn't include this line in the generated code.

Ad
source: stackoverflow.com
Ad