Hello!
I’m trying to test this endpoint to create a file in the sections folder of a selected theme. But I keep getting a non successful response.
This is the endpoint I’m working on:
app.put('/api/sections/install', async (_req, res) => {
try {
const session = res.locals.shopify.session
const asset = new shopify.api.rest.Asset({ session: session })
asset.theme_id = 97567768712
asset.key = 'sections/test-section.liquid'
asset.value = '# This is a test section created from api'
await asset.save({
update: true,
})
res.status(200).send({ value: asset.value, id: asset.theme_id })
} catch (error) {
res.status(400).send({ message: error.message })
}
})
The portion of the code that is causing the error is:
await asset.save({
update: true,
})
Please help, I have spent hours trying and searching for an answer but not getting anywhere.
Thank you in advance,