Re: bulkOperationRunMutation gives Unexpected file structure - expected JSONL

bulkOperationRunMutation gives Unexpected file structure - expected JSONL

GrantDB
Shopify Partner
74 3 14

I have been following the documentation here: https://shopify.dev/api/usage/bulk-operations/imports#generate-the-uploaded-url-and-parameters

Yet when I run bulkOperationRunMutation to run the import I get 

{u'bulkOperationRunMutation': {u'bulkOperation': None, u'userErrors': [{u'field': None, u'message': u'Unexpected file structure - expected JSONL'}]}}

I used the example file

I use this to add the file and it is successfully added

r = requests.post(self.endpoint, files=self.multipart_form_data, headers={
'X-Shopify-Access-Token': self.shopify_access_token
})

I get a response like this 

<?xml version="1.0" encoding="UTF-8"?>
<PostResponse><Location>https://shopify.s3.amazonaws.com/tmpSTUFFSTUFF</Location><Bucket>shopify</Bucket><Key>STUFFSTUFF"</ETag></PostResponse>

 

Then this to run it

r = requests.post(self.endpoint, json={'query': query}, headers={
'X-Shopify-Access-Token': self.shopify_access_token,
'X-GraphQL-Cost-Include-Fields': self.shopify_include_cost_fields
})

I am using all the data from the example, what am I missing?

Thanks

Grant

Replies 2 (2)

GrantDB
Shopify Partner
74 3 14

I think have this sorted

I was using this

self.multipart_form_data["file"] = '/servicecatalogue/development/import/products.jsonl'

But should be this I think

self.multipart_form_data["file"] = open('/servicecatalogue/development/import/products.jsonl', 'rb')

Thanks

Grant

 

Alex_kbb
Shopify Partner
1 0 0

Thx you saved my life, with this tool : https://curlconverter.com/

you can see what is the alternative in your languag. If I type 

curl --location --request POST 'https://shopify-staged-uploads.storage.googleapis.com/' \
--form 'key="tmp/21759409/bulk/2d278b12-d153-4667-a05c-a5d8181623de/bulk_op_vars"' \

 

and choose language to see how to replace the open method