I am trying to use
Post
admin/api/2020-04/carrier_services.json
HTTP/1.1 201 Created {
when I execute the following I get a list of the standard carriers, USPS, UPS and DHL, so I know the credentials are correct.
GET /admin/api/2020-04/carrier_services.json
What am I doing wrong? Or do I have to provide a working call back url in order for Shopify to setup this service?
Solved! Go to the solution
This is an accepted solution.
Hey @czupet,
I've seen this issue come up many times, and I've only ever seen it caused by sending cookies with your POST request, usually when an HTTP client like Postman is used. If deleting cookies didn't resolve the issue, can you try your request using cURL?
curl https://{username}:{password}@{shop}.myshopify.com/admin/api/2020-04/carrier_services.json -H 'Content-Type: application/json' -d "{\"carrier_service\":{\"name\":\"Shipping Rate Provider\",\"callback_url\":\"http://shippingrateprovider.com\",\"service_discovery\":true}}"
If that works, it means there's an issue with your Postman client which if causing the request to fail. If that's the case, you might want to consider using Insomnia as an alternative to Postman, it's similar but also provides native support for Shopify's GraphQL APIs.
JB | 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
Thank You very much!
You saved me!
The Carrier Service was already created so the Postman did create it, but I don't know when because when I tried it originally the service was not there when I listed services with carrier_services.json.
But each time Postman gave me the same HTML page as the response.
When I tried Insomonia it gave me an error saying the service was already created and when I listed the services indeed it was there.
So I thank you very, very much. You went way and beyond trying to help me, I do appriciated it.
Hi @_JB
Thanks for this response! We are running into the same issue (422 Unprocessable Entity error) when trying to create a CarrierService. In our case, we do not believe it has to do with cookies because we are using the Shopify-api-node package.
When we run this code:
const Shopify = new shopify({ shopName: 'xxxxxxx', accessToken: 'xxxxxxxxx' });
Shopify.carrierService.create({ name: 'app_name', callback_url: `${process.env.FORWARDING_ADDRESS}/api`, service_discovery: true, active: true, carrier_service_type: 'api' })
we get the 422 Unprocessable Entity error. Here is the header of the error response:
headers: { date: 'Tue, 07 Jul 2020 04:08:49 GMT', 'content-type': 'application/json; charset=utf-8', 'transfer-encoding': 'chunked', connection: 'close', 'set-cookie': [ '__cfduid=dec7d0e45106e8d00ac146b1dd949e4941594094929; expires=Thu, 06-Aug-20 04:08:49 GMT; path=/; domain=.myshopify.com; HttpOnly; SameSite=Lax' ], 'x-sorting-hat-podid': '151', 'x-sorting-hat-shopid': '2451177', 'referrer-policy': 'origin-when-cross-origin', 'x-frame-options': 'DENY', 'x-shopid': '2451177', 'x-shardid': '151', 'x-stats-userid': '', 'x-stats-apiclientid': '3383889', 'x-stats-apipermissionid': '261657788568', http_x_shopify_shop_api_call_limit: '1/40', 'x-shopify-shop-api-call-limit': '1/40', 'x-shopify-api-version': '2019-04', 'x-shopify-api-version-warning': 'https://shopify.dev/concepts/about-apis/versioning', 'strict-transport-security': 'max-age=7889238', 'x-request-id': 'd854f6e4-9299-4662-857c-561aa9dce708', '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.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=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fsettings%2Fshipping%2Fcarrier_services&source%5Bsection%5D=admin_api&source%5Buuid%5D=d854f6e4-9299-4662-857c-561aa9dce708", '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=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fsettings%2Fshipping%2Fcarrier_services&source%5Bsection%5D=admin_api&source%5Buuid%5D=d854f6e4-9299-4662-857c-561aa9dce708', 'x-dc': 'gcp-us-east1,gcp-us-east1', 'cf-cache-status': 'DYNAMIC', 'cf-request-id': '03c90f5cac00006dbef28b6200000001', 'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', server: 'cloudflare', 'cf-ray': '5aeeb4daa8636dbe-SJC', 'alt-svc': 'h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400' }
We confirmed that the merchant is on the Professional plan and the app has write_shipping access. We are also able to access the merchants shipping methods with:
Shopify.carrierService.list().then((c) => console.log(c));
Please advise. Thanks!
User | Count |
---|---|
13 | |
12 | |
8 | |
8 | |
4 |