A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I have an issue with bulk adding products using bulkOperationRunMutation. My code looks like that by now:
const queryString = `mutation {
stagedUploadsCreate(input:{
resource: BULK_MUTATION_VARIABLES,
filename: "test.jsonl",
mimeType: "text/jsonl",
httpMethod: POST
}){
userErrors{
field,
message
},
stagedTargets{
url,
resourceUrl,
parameters {
name,
value
}
}
}
}`;
const client = new Shopify.Clients.Graphql(
session.shop,
session.accessToken
);
const products = await client.query({
data: queryString
});
const [{ url, parameters }] = products.body.data.stagedUploadsCreate.stagedTargets;
const form = new FormData();
parameters.forEach(({name, value}) => {
form.append(name, value)
})
form.append('file', "./test.jsonl");
const response = await fetch(url, {
method: 'POST',
body: form
})
const queryStringTwo = `mutation {
bulkOperationRunMutation(
mutation: "mutation call($input: ProductInput!) { productCreate(input: $input) { product {id title variants(first: 10) {edges {node {id title inventoryQuantity }}}} userErrors { message field } } }",
stagedUploadPath: "${products.body.data.stagedUploadsCreate.stagedTargets[0].parameters[0].value}") {
bulkOperation {
id
url
status
}
userErrors {
message
field
}
}
}`
const productsBulk = await client.query({
data: queryStringTwo
});
console.log(productsBulk.body.data.bulkOperationRunMutation);
And I'm receiving this type of error:
{
bulkOperation: null,
userErrors: [
{
message: 'Unexpected file structure - expected JSONL',
field: null
}
]
}
Can you please help me with this ASAP? There is also a text.jsonl file that I'm trying to upload but in .txt extension.
Hi Mariusa202, any luck with this ? All of a sudden I started getting the same error
I am also having the same issue. Suddenly the productCreate bulk operation started throwing this error.
Hi Daniftinca,
I think i have narrowed the issue down to the line length in jsonl payload. But i am not sure if this is the issue or not. I have posted a question on this:
Thank you, will try this and maybe solve it with repeating the mutation n times without using the bulk operation as it is really not compatible with our business case to have such short lines.
Still, I would have hoped Shopify would give us a heads up if they change such important stuff in existing versions of the API.
Same problem here,.. all of a sudden,...