资产文件未通过 API 更新

问题描述 投票:0回答:1

我无法使用 2023-04 版本 REST 管理资产 API PUT 请求更新资产。 API可以找到带有主题ID和key的资产,但无法更新。

@shopify/shopify-api 版本:2023-04 节点版本:v18.14.2 操作系统:Windows


app.get("/api/single_a", verifyRequest, async (req, res) => {
  try {
    const sessionId = await shopify.session.getCurrentId({
      rawRequest: req,
      rawResponse: res,
    });
    const session = await sessionHandler.loadSession(sessionId);
   
    const client = new shopify.clients.Rest({session});
    const response = await client.get({
      path: 'themes/id/assets',
      query:{
        asset:{
          key: "assets/animations.js"
        }
      }
    });
   
    console.log("value", response.body.asset.value )
    response.body.asset.value = "<p>Heloo world </p>"
    console.log("value changed", response.body.asset.value )
     
    await client.put({
      path: `themes/id/assets`,
      data: response.body.asset
     
    });
     
    console.log("Layout of theme liquid", response);
   
    res.status(200).json({ response }); // Assuming you want to send themes as JSON
  } catch (error) {
    console.error("Error while fetching all Single Asset", error);
    res.status(500).json({ error: "An error occurred while fetching Single Asset" });
  }
});

查询返回此响应日志: 错误:收到来自 Shopify 的错误响应(404 Not Found): “未找到” 如果您报告此错误,请包含此 ID:7bfa3dfe-cda0-46cf-a522-ee4a1410b549 请解决这个问题:)

express shopify shopify-api shopify-template
1个回答
0
投票

据我所知,Shopify 不再允许应用程序使用 API 写入资产。如果您检查弃用通知,您会发现这种情况已经存在一年了。也许您将 API 版本从允许资产 API 写入的旧版本更新为不能写入的新标准?

无论如何都要检查一下。

© www.soinside.com 2019 - 2024. All rights reserved.