The JSONL file as been uploaded in single line format:
{“path”:“/store/pc/8-Eye-Black-Smooth-Boots-by-Dr-Martens-1185p76064.htm”,“target”:“/products/8-eye-black-smooth-boots-by-dr-martens”}
to the staged area and the response coming back shows all is fine. The next step is telling Shopify to process this file.
Here’s what I’m sending:
{“query”: “mutation { bulkOperationRunMutation( mutation: "mutation urlRedirectCreate($input: [UrlRedirectInput!]!) { urlRedirectCreate(input: $input) { userErrors { field message } } }", stagedUploadPath: "tmp/65599832245/bulk/2dfd4037-1a25-4ad1-a7ac-26fce90f1e21/shopify_redirect.jsonl" ) { bulkOperation { id status } userErrors { field message } } }”}
Here’s the response:
{“errors”:{“query”:“Required parameter missing or invalid”}}
I’ve tried many things, but at this point i’m going in circles. It’s something ‘obvious’, as always.
Thanks.
1 Like
Hey @Kevin_Cook ,
urlRedirectCreate
is not currently one of the supported mutations for bulk imports.
Our docs here list the compatible mutations: https://shopify.dev/docs/api/usage/bulk-operations/imports#limitations
The urlRedirectImportCreate would be more appropriate for creating redirects in bulk.
OIC. OK, well then I’ll change the format from .jsonl to .csv and use this mutation. On another note, I moved on to bulk importing orders. Can this be done in .jsonl format with orderCreate mutation or does this also need to be in .csv format with a different mutation?
Thank you for your insights!
orderCreate isn’t available for bulk imports, so you’ll need to make standard API requests for those.
So when you say ‘standard’ you mean one at a time, not to exceed 5 per minute?
Or can I upload a csv directly in the store admin?
That’s correct, there isn’t a bulk mutation to upload multiple orders in a single request.
The 5 per minute is only for trial and development stores. Stores on other plans will only be limited by the API Rate limit, so you should still be able to import them fairly quickly via API.
If you are working on a development or trial store, I’d recommend holding off on the order imports until the store is on a paid plan.
There is not a bulk order import option in the admin.
Well, I thought I was home free on this, but it appears I’m still missing something.
Once everything is prepped (.csv/upload) I run the urlRedirectImportCreate mutation:
Mutation: {“query”: “mutation { urlRedirectImportCreate(url: "https://shopify-staged-uploads.storage.googleapis.com/tmp/65599832245/redirect_imports/ed2f9d2e-60f9-450b-8994-9dcc5239c267/shopify_redirect.csv\”) { urlRedirectImport { id } userErrors { field message } } }"}
Response: {“data”:{“urlRedirectImportCreate”:{“urlRedirectImport”:{“id”:“gid://shopify/UrlRedirectImport/120684725”},“userErrors”:}},“extensions”:{“cost”:{“requestedQueryCost”:10,“actualQueryCost”:10,“throttleStatus”:{“maximumAvailable”:2000.0,“currentlyAvailable”:1990,“restoreRate”:100.0}}}}
and receive no error back.
Then based on the documentation, I run the urlRedirectImportSubmit mutation:
Mutation: {“query”: “mutation { urlRedirectImportSubmit(id: "gid://shopify/UrlRedirectImport/120684725") { userErrors { field message } } }”}
Response: {“data”:{“urlRedirectImportSubmit”:{“userErrors”:}},“extensions”:{“cost”:{“requestedQueryCost”:10,“actualQueryCost”:10,“throttleStatus”:{“maximumAvailable”:2000.0,“currentlyAvailable”:1990,“restoreRate”:100.0}}}}
and receive no error back.
At this point I assume all worked fine but there are no redirects in the store admin.
Interesting.
I do notice you have added a \
at the end of your URL. Does it work when you remove that?
Another issue that could be affecting this is redirects will only work when the path
does not exist on the store. For example, you can’t redirect an active page to an active product. You can only redirect a non-existant url to an active URL.
The \ are just escape characters so Shopify should be seeing it without the \ at the end.
This is in support of writing an app that allows a site to migrated to Shopify. So the path values are the urls minus the domain and the targets are the Shopify URL minus the domain, as in:
/store/pc/Anti-Nowhere-League-Kings-Queens-LP-Red-Vinyl–301p326486.htm /products/anti-nowhere-league-kings-queens-lp-red-vinyl
Since no error is being returned but the redirects are not appearing in the store admin, I’m a bit blind as to what to do now.
I double checked app permissions and see that “Store content
Includes personally identifiable information
View or manage articles, blogs, comments, pages, and redirects” was not checked.
I’m curious as to why the error message didn’t say the app had no permissions, but I’ll run it now and see if this is resolved.
OK, so with the permission given, still no redirects showing up. However, if I run the process twice right after another, I’m getting the response:
“message”:“Import job cannot be started while there are unfinished jobs.”}
So I believe that this is indicating the file is being processed.
Hey Kevin, thanks for sharing those details and the troubleshooting you’ve done.
Can you share the request ID from the mutation you made that didn’t show any errors but still resulted in no redirects? I’ll see what I can find out for you.
Sure, here you go Sir: gid://shopify/UrlRedirectImport/120979637
I’ve test just uploading the .csv directly in the store admin, just 2 rows, and both fail. Why, I have no idea. It’s in the format shown in the documentation.
it’s complaining about the Target being blank, even though it isn’t. Has to be a structure issue I can’t see. I’ll continue to do some tests and flush it out.
OK, I’ve pulled the screwdriver out of my thigh, I feel much better now!
So the issue was that the headers had a space after the comma: Redirect from, Redirect to - should be Redirect from,Redirect to
Amazing that little space caused all of this hoopla.