Closed Bek81 closed 5 years ago
See https://github.com/MONEI/Shopify-api-node/issues/174#issuecomment-377222096 it seems the same.
"Great Scott!"...It works!
Thanks a lot @lpinca .
Now all I have to do is try to load the file in another store and find a way to manage the images uploaded via the section widget ("image": "shopify: / shop_images / flagship_miami_01.jpg").
with ttt = JSON string and shopify.asset.update(ANOTHERTHEMEIDOFANOTHERSTORE, params)
let params = {
asset: {
key: "config/settings_data.json",
value: ttt
}
}
return statusCode: 406, statusMessage: "Not Acceptable"
params = {
key: "config/settings_data.json",
value: ttt
}
return statusCode: 422, statusMessage: "Unprocessable Entity"
I don't think you can change the theme of another store from the same Shopify
instance. You probably have to create another Shopify
instance for that store and use it.
Yes....I'm using another instance of API (connected to another store).
another_shopify_instance.asset.update(ANOTHERTHEMEIDOFANOTHERSTORE, params)
Try to read the error message if there is one.
try {
await shopify.asset.update(id, { key: '...', src: '...' });
} catch (err) {
console.log(err.response.body)
}
await shopify.asset.update(38248185907, params)
SyntaxError: await is only valid in async function
{ key: '...', src: '...' } I set "value" for JSON. Like for working example:
key: 'templates/collection.beky.liquid',
value: "{% section 'beky' %}"
the errors are already written above:
return statusCode: 406, statusMessage: "Not Acceptable"
or
return statusCode: 422, statusMessage: "Unprocessable Entity"
Thanks
yes, 422 means one of the parameter is invalid, you should get more info by reading the error message.
shopify.asset.update(id, { key: '...', /* ... */ })
.then(console.log)
.catch((err) => console.error(err.response.body));
ok, I found.
The right version is
params = {
key: "config/settings_data.json",
value: ttt
}
now err.response.body is:
{ errors:
{ asset:
[ 'Invalid type value for block \'1552992990111\'. Type must be defined in schema',
'Invalid type value for block \'footer-1\'. Type must be defined in schema',
'Invalid type value for block \'1558012537942\'. Type must be defined in schema',
'Invalid type value for block \'1558012487774\'. Type must be defined in schema',
'Invalid type value for block \'1558013871932\'. Type must be defined in schema',
'Invalid type value for block \'1558013914337\'. Type must be defined in schema',
'Invalid type value for block \'collection-0\'. Type must be defined in schema',
'Invalid type value for block \'collection-1\'. Type must be defined in schema',
'Invalid type value for block \'collection-2\'. Type must be defined in schema',
'Invalid type value for block \'1553170432378-0\'. Type must be defined in schema',
'Preset \'Allure\' Invalid type value for block \'footer-1\'. Type must be defined in schema',
'Preset \'Allure\' Invalid type value for block \'collection-0\'. Type must be defined in schema',
'Preset \'Allure\' Invalid type value for block \'collection-1\'. Type must be defined in schema',
'Preset \'Allure\' Invalid type value for block \'collection-2\'. Type must be defined in schema',
'Preset \'Couture\' Invalid type value for block \'footer-1\'. Type must be defined in schema',
'Preset \'Couture\' Invalid type value for block \'collection-0\'. Type must be defined in schema',
'Preset \'Couture\' Invalid type value for block \'collection-1\'. Type must be defined in schema',
'Preset \'Couture\' Invalid type value for block \'collection-2\'. Type must be defined in schema',
'Preset \'Vogue\' Invalid type value for block \'footer-1\'. Type must be defined in schema',
'Preset \'Vogue\' Invalid type value for block \'collection-0\'. Type must be defined in schema',
'Preset \'Vogue\' Invalid type value for block \'collection-1\'. Type must be defined in schema',
'Preset \'Vogue\' Invalid type value for block \'collection-2\'. Type must be defined in schema' ] } }
But i import a zip with whole theme from the first store. I think this is a big problem to do what I try to do.
Benedetto
I don't know but it isn't an issue in the library.
I'm afraid not. But I wish I had an answer from the developers.
Anyway, thanks a lot @lpinca .
Closing as there is nothing actionable to do on our side.
Hi,
testing the native shopify API to get the "config/settings_data.json" file, the data returns correctly.
I used:
https://SITENAME.myshopify.com/admin/themes/THEMEID/assets.json?asset[key]=config/settings_data.json
When i try to get that data using this Node Api (connected to the same store):
I get an "undefined".
Can you help me, please?
Moreover, is it possible to upload the same JSON in another store?
Thanks a lot.