【问题标题】:Error trying to update customer on Microsoft Dynamics 365 Business Central using API尝试使用 API 在 Microsoft Dynamics 365 Business Central 上更新客户时出错
【发布时间】:2021-05-28 10:41:54
【问题描述】:

我正在尝试使用 API 在 Microsoft Dynamics 365 Business Central 中更新客户。我正在使用 Postman 调用 API

但是,当我尝试进行更新时,我收到以下错误:-

"error": {
    "code": "BadRequest_ResourceNotFound",
    "message": "Resource not found for the segment 'customer'.  CorrelationId:  b5593eb6-2074-41fe-9106-d7bbdba8b452."
}

它创造了客户罚款。如果我使用 Dynamics Web UI 创建客户,那么我可以通过 API 对其进行更新。只有当我通过 API 创建客户并尝试更新它时,才会出现此问题。

这是我用来创建客户的 json

{
    "displayName": "Adatum Corporation",
    "type": "Company",
    "addressLine1": "192 Market Square",
    "addressLine2": "",
    "city": "Atlanta",
    "state": "GA",
    "country": "US",
    "postalCode": "31772",
    "phoneNumber": "",
    "email": "robert.townes@contoso.com",
    "website": "",
    "taxLiable": true,
    "blocked": " "
}

这是我用来更新的 Json

{
    "displayName": "Some other name"
}

看了好几个小时,我就是想不通我做错了什么。有人有什么想法吗?

这是我正在使用的端点:

https://api.businesscentral.dynamics.com/v2.0/{id}/Production/api/v2.0/companies({id})/customers({customerid})

【问题讨论】:

  • 您能否添加有关您正在使用的端点的信息?
  • 当然,我一直在使用这个:api.businesscentral.dynamics.com/v2.0{id}/Production/api/v2.0/companies({id})/customers({customerid})

标签: dynamics-365 dynamics-business-central


【解决方案1】:

您必须使用customers(复数形式),然后它应该可以工作。 Web API Create 和 Update 文档。

POST businesscentralPrefix/companies({id})/customers

PATCH businesscentralPrefix/companies({id})/customers({id})

通常,当找不到X 表/实体时会发生此Resource not found for the segment 'X' 错误。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-15
  • 2021-09-23
  • 1970-01-01
  • 2021-11-22
相关资源
最近更新 更多