API Function Definitions

Solved
Highlighted
Excursionist
15 1 1

Forgive my ignorance, but I have not been able to locate a document or site where the API functions are defined or how to call them with JSON code.  I am trying to write a windows application that will pull/push information to the Shopify store and feed an SQL Server database.

0 Likes
Highlighted
Shopify Partner
1676 207 335

https://www.google.com/search?q=shopify+rest+api ? :)

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 168

Unfortunately, part of the top search result when clicking the above Google link is missing a lot of information right now and may not be the most useful. Working on getting that fixed, though. 

 

What kind of information were you interested in pushing/pulling from Shopify? If you were interested in order information, for example, you'd want to look here. But if you could share some more specific details it would be easier to give you some direction. 

0 Likes
Highlighted
Excursionist
15 1 1

Specifically here is what I need to to do:

1. Get a list of orders received on a given date. (this is working)

2. Get a list of products. (this is working)

3. Update a product/variant information: price and quantity available. - NOT WORKING

4. Add new product/variant. - NOT WORKING

5. Get a list of customers. (this is working)

6. Add new customers. - NOT WORKING

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 168

Hey @TxBob77 , 

 

What specifically about these isn't working? Are there errors and error messages? Is this all on the same shop? Are you able to provide examples or request IDs for these issues?

0 Likes
Highlighted
Excursionist
15 1 1

Example I have tried every API call I can find to update a Product/Variant/Inventory Item available quantity.  They ALL return the same basic error.  I can not tell why they are failing: An example of my post this morning is:

 

POST https://allergystore-com.myshopify.com/admin/api/2019-10/inventory_levels/set.json{"available":%2029...} HTTP/1.1
User-Agent: West Wind Internet Protocols 7.07
Host: allergystore-com.myshopify.com
Content-Length: 0
Cache-Control: no-cache
Cookie: _master_udr=eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWxoWldWa01qTXhNUzA1TVRsa0xUUmxOamt0T1RSbE1DMHdNR00xTXpZNU5XWXdZelFHT2daRlJnPT0iLCJleHAiOiIyMDIxLTExLTA3VDE3OjA3OjM2LjM5MFoiLCJwdXIiOiJjb29raWUuX21hc3Rlcl91ZHIifX0%3D--e1f8b30de31ec7c039f6990e0269c7f3443b98b6; _secure_admin_session_id=d67e3220d5777f1e5e5ce816d704e6d5; _secure_admin_session_id_csrf=d67e3220d5777f1e5e5ce816d704e6d5; shopify_web_return_to=%2Fadmin%2Fapi%2F2019-10%2Fproducts.json; _orig_referrer=; _landing_page=%2Fadmin%2Fauth%2Flogin; __cfduid=d5098f712748dbd9290a5c2da0eac147d1565615518; _y=6ac27dd7-ad25-4ed0-a8fe-ee1b76507eaa; _shopify_y=6ac27dd7-ad25-4ed0-a8fe-ee1b76507eaa; _shopify_fs=2019-10-17T20%3A30%3A14.155Z
Authorization: Basic MDU5MDNlMWI4OGJjZTM1ZDhmMGVmNmQxYWVhYTdiMzk6YmJmZmYyYmI2NDNiOTFjYjU1MzM5Yzc1OWM4ZWRjODM=

 

the return is:

HTTP/1.1 303 See Other
Date: Fri, 08 Nov 2019 16:02:49 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Sorting-Hat-PodId: 137
X-Sorting-Hat-ShopId: 5531959367
Referrer-Policy: origin-when-cross-origin
X-Frame-Options: DENY
X-ShopId: 5531959367
X-ShardId: 137
Cache-Control: no-cache, no-store
Location: https://allergystore-com.myshopify.com/admin/auth/login
Strict-Transport-Security: max-age=7889238
Set-Cookie: request_method=POST; path=/
X-Shopify-Stage: production
Content-Security-Policy: default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopify.cn https://checkout.shopifycs.com https://js-agent.newrelic.com https://bam.nr-data.net https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com https://widget.intercom.io https://js.intercomcdn.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=error_404&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Ferrors&source%5Bsection%5D=admin&source%5Buuid%5D=44892c35-a5cd-48eb-933f-dd88004ad635
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block; report=/xss-report?source%5Baction%5D=error_404&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Ferrors&source%5Bsection%5D=admin&source%5Buuid%5D=44892c35-a5cd-48eb-933f-dd88004ad635
X-Dc: gcp-us-east1,gcp-us-central1,gcp-us-central1
NEL: {"report_to":"network-errors","max_age":2592000,"failure_fraction":0.01,"success_fraction":0.0001}
Report-To: {"group":"network-errors","max_age":2592000,"endpoints":[{"url":"https://monorail-edge.shopifycloud.com/v1/reports/nel/20190325/shopify"}]}
X-Request-ID: 44892c35-a5cd-48eb-933f-dd88004ad635
NEL: {"report_to":"network-errors","max_age":2592000,"failure_fraction":0.01,"success_fraction":0.0001}
Report-To: {"group":"network-errors","max_age":2592000,"endpoints":[{"url":"https://monorail-edge.shopifycloud.com/v1/reports/nel/20190325/shopify"}]}
CF-Cache-Status: DYNAMIC
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5328c604e852c7f2-DFW

79
<html><body>You are being <a href="https://allergystore-com.myshopify.com/admin/auth/login">redirected</a>.</body></html>
0

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 168

This is an accepted solution.

Hey @TxBob77 , 

 

There's something strange with your request, are your headers being set properly? What are you sending these requests with? 

 

Our logs are showing a POST request to : "/admin/api/2019-10/inventory_levels/set.json%7B%22available%22:%2029,%22inventory_item_id%22:%2017422296514631,%22location_id%22:%2018261278791%7D" 

 

Where your request is being sent with the body as URL-encoded params. I'm not sure if that's intentional or not, but you should be making a POST to "/admin/api/2019-10/inventory_levels/set.json" instead with a JSON request body, not URL params. 

 

If that's a change you're able to make, that should get this sorted out. 

 

 

1 Like
Highlighted
Excursionist
15 1 1

I guess I am confused as to how to put the json object in the request BODY

0 Likes
Highlighted
Excursionist
15 1 1

Thank you.  I am still not able to post but that is due to my post is still using cookies.  But I was able to figure out how to post the request with the json object in the body. 

0 Likes