How To GET Resources From Shopify API Admin Endpoint Using Rails
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?
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).
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.
Related Questions
- → Trigger a click with jQuery using link_to of rails 4
- → Adding html data attribute to simple_forms input
- → How to remove parameters from the root URL if it does I18n
- → passing parameters to rails back end from an ajax call
- → Blocking ?page= in robots.txt
- → react js and rails Updating state on a component with active record relationship
- → Kaminari How to process routes as javascript
- → State not passed into prop
- → Cannot read property 'modalIsOpen' of undefined
- → Objects not valid issue
- → How to map API params to model
- → Consuming webhooks shopify-api
- → How to add ScriptTag on shopify_api gem?