Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shopify.Fulfillment.create doesn't work? #732

Open
noname004 opened this issue Aug 9, 2024 · 0 comments
Open

shopify.Fulfillment.create doesn't work? #732

noname004 opened this issue Aug 9, 2024 · 0 comments

Comments

@noname004
Copy link

noname004 commented Aug 9, 2024

when I use "shopify.Fulfillment.create(fulfillment_data)" an error show as follows:

pyactiveresource.connection.ClientError: Response(code=406, body="b''", headers={'Date': 'Fri, 09 Aug 2024 09:16:16 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'close', 'X-Sorting-Hat-PodId': '156', 'X-Sorting-Hat-ShopId': '67398467741', 'referrer-policy': 'origin-when-cross-origin', 'x-frame-options': 'DENY', 'x-shopid': '67398467741', 'x-shardid': '156', 'x-stats-userid': '', 'x-stats-apiclientid': '144743825409', 'x-stats-apipermissionid': '551509229725', 'x-shopify-api-version': '2023-10', 'http_x_shopify_shop_api_call_limit': '1/40', 'x-shopify-shop-api-call-limit': '1/40', 'strict-transport-security': 'max-age=7889238', 'x-request-id': '927d8293-5b2c-4f73-9736-38f35d231b99-1723194976', 'server-timing': 'processing;dur=29', '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=error_404&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Ferrors&source%5Bsection%5D=admin_api&source%5Buuid%5D=927d8293-5b2c-4f73-9736-38f35d231b99-1723194976", '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=927d8293-5b2c-4f73-9736-38f35d231b99-1723194976', 'x-dc': 'gcp-asia-southeast1,gcp-us-east1,gcp-us-east1', 'CF-Cache-Status': 'DYNAMIC', 'Report-To': '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=vk1ms%2B7IVJ5fco%2FcfcE6IOP%2BlK7Wy5dDsD0A27oHjlPNRDTj52leQmmdtsv%2FyQqKCdKE1z99cYNDXW6zy1SAqRKlLh%2FWCUrjcJcPPToOSd%2BqnVI6%2Fs7ZlmZaZlha%2FV0EIeWbgjyexdDc"}],"group":"cf-nel","max_age":604800}', 'NEL': '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}', 'Server-Timing': 'processing;dur=29', 'Server': 'cloudflare', 'CF-RAY': '8b06a57a0dc8107f-HKG', 'alt-svc': 'h3=":443"; ma=86400'}, msg="Not Acceptable")


And this is my code:

shop_url = "https://%s:%[email protected]/admin" % (API_KEY, PASSWORD)
shopify.ShopifyResource.set_site(shop_url)
shopify.ShopifyResource.set_version('2024-07')

order_data = {
"line_items": [
{"variant_id": 12651274731677, "quantity": 6, "price": 8, "title": "some shoe"}
],
"customer": {
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]"
},
"shipping_address": {
"first_name": "John",
"last_name": "Doe",
"address1": "123 Elm St",
"city": "Springfield",
"province": "IL",
"country": "US",
"zip": "62701"
}
}

order = shopify.Order.create(order_data)

fulfillment_data = {
"order_id": order.id,
"tracking_number": "1Z12345E0205271688",
"tracking_url": "https://example.com/track/1Z12345E0205271688",
"tracking_company": "EMS",
"line_items": [{"id": line_item.id, "quantity": line_item.quantity} for line_item in order.line_items]
}

fulfillment = shopify.Fulfillment.create(fulfillment_data)
if fulfillment.errors:
print("Failed to create fulfillment:", fulfillment.errors.full_messages())
else:
print("Fulfillment created successfully:", fulfillment.id)


I spent a long time trying to find the reason for the 406 error, but I couldn't find it. I checked the API docs and the url seemed to be different. Is this API invalid? Can anyone tell me the reason and how to solve this problem??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant