You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过REST API在Dynamics 365 Business Central中创建客户收货地址

使用Dynamics 365 Business Central开箱即用REST API创建客户收货地址(Ship-To Address)

核心逻辑

Business Central的开箱即用REST API里,收货地址是customerShipToAddresses资源,属于客户(customers)的子资源,得通过客户资源的关联端点创建,而非独立的顶级端点,这也是容易被忽略的点。

具体操作步骤

  • 确认API版本:用v2.0及以上版本的Business Central API,旧版本可能不支持该子资源。
  • 获取目标客户ID:先通过customers端点查到要关联地址的客户ID,示例请求:
    GET https://api.businesscentral.dynamics.com/v2.0/{tenantId}/api/v2.0/companies/{companyId}/customers?$filter=number eq 'CUST001'
    
  • 创建收货地址:调用客户的关联端点customerShipToAddresses发送POST请求:
    • 请求端点:
      POST https://api.businesscentral.dynamics.com/v2.0/{tenantId}/api/v2.0/companies/{companyId}/customers/{customerId}/customerShipToAddresses
      
    • 请求体(JSON格式):
      {
        "code": "SHIP001",
        "displayName": "主仓库",
        "addressLine1": "工业路123号",
        "city": "上海",
        "state": "上海市",
        "postalCode": "200000",
        "country": "CN"
      }
      
    注意:code是该客户下收货地址的唯一标识,每个客户的地址code不能重复;displayName是地址名称,其他字段按需补充即可。

常见注意事项

  • 权限配置:API应用必须拥有Customers.ReadWrite.All权限范围,否则会触发权限不足的错误。
  • 字段验证:Business Central对地址字段有内置规则(比如邮编格式、国家代码规范),要确保请求体字段符合系统要求。
  • 批量处理:如果要批量导入多个收货地址,只能循环对每个客户的关联端点发送POST请求,目前开箱即用API不支持批量提交。

内容的提问来源于stack exchange,提问作者user2047618

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 12:32:06