Shopify / shopify_python_api

ShopifyAPI library allows Python developers to programmatically access the admin section of stores
http://shopify.github.io/shopify_python_api
MIT License
1.23k stars 350 forks source link

product.save() doesn't appear to be working #731

Open cmogush opened 1 month ago

cmogush commented 1 month ago

Issue summary

Write a short description of the issue here ↓ product.save() doesn't seem to be saving the product

Expected behavior

A newly created product, or existing product with modifications, should save when call the product.save() method

Actual behavior

When called on a new product, nothing happens. When called on an existing product, an error is thrown

pyactiveresource.connection.Redirection: Response(code=301, body="b''", headers={'Date': 'Fri, 19 Jul 2024 18:39:19 GMT', 'Content-Type': 'text/html; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'close', 'X-Sorting-Hat-PodId': '294', 'X-Sorting-Hat-ShopId': '80191488295', 'referrer-policy': 'origin-when-cross-origin', 'x-frame-options': 'DENY', 'x-shopid': '80191488295', 'x-shardid': '294', 'location': 'https://711923-2.myshopify.com/admin/api/2022-07/products/9468056895783.json', 'strict-transport-security': 'max-age=7889238', 'set-cookie': 'request_method=PUT; path=/; SameSite=Lax', 'x-request-id': 'e8adfc04-1fbe-471e-b8c6-4ff2ba5c18b1-1721414359', 'server-timing': 'processing;dur=34, socket_queue;dur=3.042, edge;dur=2.045, util;dur=0.111, memcache;dur=6.135, redis;dur=0.0, db;dur=1.712, elasticsearch;dur=0.0, view;dur=0.0, externals;dur=7.847, graphql_lex;desc="GraphQL Lexing";dur=0.0, graphql_parse;desc="GraphQL Parsing";dur=0.0, graphql_execute;desc="GraphQL Execution";dur=0.0, graphql_analyze;desc="GraphQL Analysis";dur=0.0, graphql_validate;desc="GraphQL Static Validation";dur=0.0', 'server-timing-public': 'processing;dur=34', '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.shopifycdn.net/ https://checkout.shopifycs.com/ 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/ 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=update&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fproducts&source%5Bsection%5D=admin_api&source%5Buuid%5D=e8adfc04-1fbe-471e-b8c6-4ff2ba5c18b1-1721414359", '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=update&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fproducts&source%5Bsection%5D=admin_api&source%5Buuid%5D=e8adfc04-1fbe-471e-b8c6-4ff2ba5c18b1-1721414359', 'x-dc': 'gcp-us-east4,gcp-us-central1,gcp-us-central1', 'CF-Cache-Status': 'DYNAMIC', 'Report-To': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=M5sw4C2u34o7gMg2tcbhAchfWcXCP0L0gTnCTh0oNkiz81%2FvFot8koSMcY%2FWrtxCSa5%2FMECPo3vKTaVGkOZp9bnD4RhnuOCmxNNIuxZf1s8N9qu3rrArnFbjgbiSu5q5Jx0vRn5KuKwytvC5K%2BU%3D"}],"group":"cf-nel","max_age":604800}', 'NEL': '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}', 'Server-Timing': 'processing;dur=34, socket_queue;dur=3.042, edge;dur=2.045, util;dur=0.111, memcache;dur=6.135, redis;dur=0.0, db;dur=1.712, elasticsearch;dur=0.0, view;dur=0.0, externals;dur=7.847, graphql_lex;desc="GraphQL Lexing";dur=0.0, graphql_parse;desc="GraphQL Parsing";dur=0.0, graphql_execute;desc="GraphQL Execution";dur=0.0, graphql_analyze;desc="GraphQL Analysis";dur=0.0, graphql_validate;desc="GraphQL Static Validation";dur=0.0', 'Server': 'cloudflare', 'CF-RAY': '8a5cd56108731438-PIT', 'alt-svc': 'h3=":443"; ma=86400'}, msg="Moved Permanently")

Steps to reproduce the problem

For new product

  1. session = startShopifySession() product = shopify.Product() product.title = "Test Product" product.save()
  2. Check the inventory and there are no new products seen.

For existing product

  1. session = startShopifySession() product = shopify.Product.find(9468056895783) product.price = "9.99" product.save()
  2. receive the error message:
    pyactiveresource.connection.Redirection: Response(code=301, body="b''", headers={'Date': 'Fri, 19 Jul 2024 18:39:19 GMT', 'Content-Type': 'text/html; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'close', 'X-Sorting-Hat-PodId': '294', 'X-Sorting-Hat-ShopId': '80191488295', 'referrer-policy': 'origin-when-cross-origin', 'x-frame-options': 'DENY', 'x-shopid': '80191488295', 'x-shardid': '294', 'location': 'https://711923-2.myshopify.com/admin/api/2022-07/products/9468056895783.json', 'strict-transport-security': 'max-age=7889238', 'set-cookie': 'request_method=PUT; path=/; SameSite=Lax', 'x-request-id': 'e8adfc04-1fbe-471e-b8c6-4ff2ba5c18b1-1721414359', 'server-timing': 'processing;dur=34, socket_queue;dur=3.042, edge;dur=2.045, util;dur=0.111, memcache;dur=6.135, redis;dur=0.0, db;dur=1.712, elasticsearch;dur=0.0, view;dur=0.0, externals;dur=7.847, graphql_lex;desc="GraphQL Lexing";dur=0.0, graphql_parse;desc="GraphQL Parsing";dur=0.0, graphql_execute;desc="GraphQL Execution";dur=0.0, graphql_analyze;desc="GraphQL Analysis";dur=0.0, graphql_validate;desc="GraphQL Static Validation";dur=0.0', 'server-timing-public': 'processing;dur=34', '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.shopifycdn.net/ https://checkout.shopifycs.com/ 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/ 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=update&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fproducts&source%5Bsection%5D=admin_api&source%5Buuid%5D=e8adfc04-1fbe-471e-b8c6-4ff2ba5c18b1-1721414359", '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=update&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fproducts&source%5Bsection%5D=admin_api&source%5Buuid%5D=e8adfc04-1fbe-471e-b8c6-4ff2ba5c18b1-1721414359', 'x-dc': 'gcp-us-east4,gcp-us-central1,gcp-us-central1', 'CF-Cache-Status': 'DYNAMIC', 'Report-To': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=M5sw4C2u34o7gMg2tcbhAchfWcXCP0L0gTnCTh0oNkiz81%2FvFot8koSMcY%2FWrtxCSa5%2FMECPo3vKTaVGkOZp9bnD4RhnuOCmxNNIuxZf1s8N9qu3rrArnFbjgbiSu5q5Jx0vRn5KuKwytvC5K%2BU%3D"}],"group":"cf-nel","max_age":604800}', 'NEL': '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}', 'Server-Timing': 'processing;dur=34, socket_queue;dur=3.042, edge;dur=2.045, util;dur=0.111, memcache;dur=6.135, redis;dur=0.0, db;dur=1.712, elasticsearch;dur=0.0, view;dur=0.0, externals;dur=7.847, graphql_lex;desc="GraphQL Lexing";dur=0.0, graphql_parse;desc="GraphQL Parsing";dur=0.0, graphql_execute;desc="GraphQL Execution";dur=0.0, graphql_analyze;desc="GraphQL Analysis";dur=0.0, graphql_validate;desc="GraphQL Static Validation";dur=0.0', 'Server': 'cloudflare', 'CF-RAY': '8a5cd56108731438-PIT', 'alt-svc': 'h3=":443"; ma=86400'}, msg="Moved Permanently")

I realize I am new to this, and I apologize if this isn't an actual bug but maybe I'm doing something wrong. I tried to find supporting documentation and scoured this Git, Google, Shopify developer help boards, and even made several posting there, but still cannot solve this issue. If there is a better resource or place to assist with this, I'll gladly check elsewhere. Any help or guidance pointing me in the right direction is greatly appreciated. Thank you!

sillycube commented 1 month ago

The /products and /variants endpoints are deprecated: https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model#whats-changing