I have orders that were placed with Shopify, but were paid with an external payment system. I am trying to mark them as paid using the Python API, but am getting a 406 response when saving the transaction. The private app in the store has read and write set for Orders API
shop_url = "https://%s:%s@mystore.myshopify.com/admin/api/%s" % (API_KEY, PASSWORD, API_VERSION)
shopify.ShopifyResource.set_site(shop_url)shop = shopify.Shop.current();
order = shopify.Order.find_first(name="#20204512");
trans = shopify.Transaction.find_first(order_id=order.id);
new_transaction = shopify.Transaction();
new_transaction.currency = "CAD";
new_transaction.kind = "capture"
new_transaction.status = "paid"
new_transaction.gateway = "manual"
new_transaction.amount = "10.00";
new_transaction.parent_id = trans.id;
new_transaction.save();
Hey @Tiber
Can you provide us the request id response header so we can take a look in our logs? Normally when we see a 406 it's some kind of malformed URL.
Kevin_A | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Not sure if it is one of these?
'X-Request-ID': '06201c5f-c654-4502-87fe-a427007d2f63'
cf-request-id': '05677d047d0000ca948e31f200000001
Here is the complete response.
Message=Response(code=406, body="b''", headers={'Date': 'Fri, 25 Sep 2020 15:31:23 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'close', 'Set-Cookie': '__cfduid=de6b87343889f57f8c811cb935199eb301601047882; expires=Sun, 25-Oct-20 15:31:22 GMT; path=/; domain=.myshopify.com; HttpOnly; SameSite=Lax', 'X-Sorting-Hat-PodId': '41', 'X-Sorting-Hat-ShopId': '27892074', 'Referrer-Policy': 'origin-when-cross-origin', 'X-Frame-Options': 'DENY', 'X-ShopId': '27892074', 'X-ShardId': '41', 'X-Stats-UserId': '', 'X-Stats-ApiClientId': '4174557', 'X-Stats-ApiPermissionId': '205048643626', 'X-Shopify-API-Terms': 'By accessing or using the Shopify API you agree to the Shopify API License and Terms of Use at https://www.shopify.com/legal/api-terms', 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT': '2/40', 'X-Shopify-Shop-Api-Call-Limit': '2/40', 'X-Shopify-API-Version': '2020-07', 'Strict-Transport-Security': 'max-age=7889238', '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.shopifycdn.net https://checkout.us.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_api&source%5Buuid%5D=06201c5f-c654-4502-87fe-a427007d2f63", '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_api&source%5Buuid%5D=06201c5f-c654-4502-87fe-a427007d2f63', 'X-Dc': 'gcp-us-central1,gcp-us-east1,gcp-us-east1', 'X-Request-ID': '06201c5f-c654-4502-87fe-a427007d2f63', 'CF-Cache-Status': 'DYNAMIC', 'cf-request-id': '05677d047d0000ca948e31f200000001', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare', 'CF-RAY': '5d85cab3fd07ca94-YYZ', 'alt-svc': 'h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400'}, msg="Not Acceptable")
Hey @Tiber
Sorry for not clarifying, it's the x-request-id that is the important one. Here is the request URL that you are sending to us:
/admin/api/2020-07/orders//transactions.json
As you can see, it doesn't appear as though you are submitting an order ID. Since you are using the Python API, my best guess would be that you are passing a null parameter somewhere.
Kevin_A | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
User | Count |
---|---|
13 | |
12 | |
10 | |
8 | |
8 |