Demandware OCAPI 修改命令

Demandware OCAPI modify order

我构建了一个小程序,可以帮助识别 Demandware 中状态不正确的订单,例如:(状态:新的、打开的、完成的和发货状态:未发货、已发货)。

我基本上只是使用 OCAPI 中的 order_search 并将结果与​​我们的 ERP 进行比较。

但是现在我想自动修复一些状态,这需要我使用 /orders/{order_no} GET 和 PATCH 调用,但是当我这样做时,我得到以下信息留言:

{ type: 'AccessWithoutUserForbiddenException',
 message: 'An authenticated user is required in order to access resource.' }

根据 order_search 的文档 OAUTH 使用:"Authentication via OAuth token.",但是命令/{order_no} 使用:"Authentication via OAuth token. A valid user is required."

那么成为有效用户的正确策略是什么?

获取 oAuth 令牌的有效用户是商务管理平台用户。因此,请登录商务管理平台并为您的用例创建一个新用户并授予必要的权限。

之后您就可以执行特定资源了。

基督教徒

如果您使用 account.demandware.com 作为主机,那么它将抛出以下错误

{ error: 'unauthorized_client', error_description: 'Client id \'xxxxxxxxxxxxxxxxxxx\' has invalid credentials to use grant type \'urn:demandware:params:oauth:grant-type:client-id:dwsid:dwsecuretoken\'.' }

相反,您可以将主机更改为您的沙盒主机。再试一次。它应该工作。我也遇到了同样的问题。

const key = new Buffer('business_manager_email_id' + ":" + 'business_manager_pwd' + ":" + 'client_pwd').toString("base64");
const options = {
    url: 'https://<sandbox_host>/dw/oauth2/access_token?client_id=your_client_id',
    method: "POST",
    headers: {
      'Authorization': "Basic " + key,
      "Content-Type": "application/x-www-form-urlencoded",
    },
    body: "grant_type=urn:demandware:params:oauth:grant-type:client-id:dwsid:dwsecuretoken"
  };