我们已经在我们的服务器上安装了 MS Dynamics 365 Business Central(我不知道如何查看当前安装的版本)。我们正在为我们的请求使用oData v4协议。
任务
我们需要从 PHP 对该系统进行 API 调用问题
当 GET 请求运行良好时,不可能发出 POST、PATCH、DELETE 请求。得到
要求:
获取 https://d365bc.vendor.com:7058/attain/ODataV4/Company('{{company}}')/Customer回复
{
"@odata.context": "https://d365bc.vendor.com:7058/attain/ODataV4/$metadata#Company('...')/Customer",
"value": [
{
"@odata.etag": "W/\"JzQ0O29EcmJmcGs4V3NRMHlEQ0Fxa0JxL1N0bi9xZjY5UDFQakZ0U2tBUGU1Kzg9MTswMDsn\"",
"No": "01121212",
"Name": "Spotsmeyer's Furnishings",
"Responsibility_Center": "",
"Location_Code": "YELLOW",
"Post_Code": "US-FL 37125",
"Country_Region_Code": "US",
"Phone_No": "",
"IC_Partner_Code": "",
"Contact": "Mr. Mike Nash",
"Salesperson_Code": "JR",
"Customer_Posting_Group": "FOREIGN",
"Gen_Bus_Posting_Group": "EXPORT",
"VAT_Bus_Posting_Group": "EXPORT",
"Customer_Price_Group": "",
"Customer_Disc_Group": "",
"Payment_Terms_Code": "1M(8D)",
"Reminder_Terms_Code": "FOREIGN",
"Fin_Charge_Terms_Code": "2.0 FOR.",
"Currency_Code": "USD",
"Language_Code": "ENU",
"Search_Name": "SPOTSMEYER'S FURNISHINGS",
"Credit_Limit_LCY": 0,
"Blocked": " ",
"Privacy_Blocked": false,
"Last_Date_Modified": "2020-06-18",
"Application_Method": "Manual",
"Combine_Shipments": true,
"Reserve": "Optional",
"Shipping_Advice": "Partial",
"Shipping_Agent_Code": "",
"Base_Calendar_Code": "",
"Balance_LCY": 0,
"Balance_Due_LCY": 0,
"Sales_LCY": 0,
"Global_Dimension_1_Filter": "",
"Global_Dimension_2_Filter": "",
"Currency_Filter": "",
"Date_Filter": "..11/13/20"
},
{
"@odata.etag": "W/\"JzQ0O08vNlVHSWVaZ1FGeG42d2JOa3k4Qm5uVHlkSGYzNk1ES2V5Y2E2S3hiekU9MTswMDsn\"",
"No": "01445544",
"Name": "Progressive Home Furnishings",
"Responsibility_Center": "",
"Location_Code": "YELLOW",
"Post_Code": "US-IL 61236",
"Country_Region_Code": "US",
"Phone_No": "",
"IC_Partner_Code": "",
"Contact": "Mr. Scott Mitchell",
"Salesperson_Code": "JR",
"Customer_Posting_Group": "FOREIGN",
"Gen_Bus_Posting_Group": "EXPORT",
"VAT_Bus_Posting_Group": "EXPORT",
"Customer_Price_Group": "",
"Customer_Disc_Group": "RETAIL",
"Payment_Terms_Code": "14 DAYS",
"Reminder_Terms_Code": "FOREIGN",
"Fin_Charge_Terms_Code": "2.0 FOR.",
"Currency_Code": "USD",
"Language_Code": "ENU",
"Search_Name": "PROGRESSIVE HOME FURNISHINGS",
"Credit_Limit_LCY": 0,
"Blocked": " ",
"Privacy_Blocked": false,
"Last_Date_Modified": "2018-09-19",
"Application_Method": "Manual",
"Combine_Shipments": true,
"Reserve": "Optional",
"Shipping_Advice": "Partial",
"Shipping_Agent_Code": "",
"Base_Calendar_Code": "",
"Balance_LCY": 1499.03,
"Balance_Due_LCY": 1499.03,
"Sales_LCY": 1499.03,
"Global_Dimension_1_Filter": "",
"Global_Dimension_2_Filter": "",
"Currency_Filter": "",
"Date_Filter": "..11/13/20"
},
删除
删除 https://d365bc.vendor.com:7058/attain/ODataV4/Company('{{company}}')/Customer(No='01121212'){
"error": {
"code": "BadRequest",
"message": "Entity does not support delete."
}
}
我不确定 Create (POST) 或 Update (Patch) 的正确语法是什么 对于 POST 请求,我尝试复制现有值(取自 GET)并将其放入正文中。我收到以下回复:
{
"error": {
"code": "BadRequest_MethodNotAllowed",
"message": "Entity does not support insert."
}
}
有时,如果我提出绝对错误的请求,我会收到以下回复:
{
"error": {
"code": "BadRequest_MethodNotAllowed",
"message": "'POST' requests for 'Customer' of EdmType 'Entity' are not allowed within Microsoft Dynamics 365 Business Central OData web services."
}
}
我无法为客户 ProductItems 应用 CUD 操作。但是对于订单,它可以工作。
现有特权
如果我跟随设置和扩展 / 手动设置 / 用户 / [选择用户]
在权限部分,分配的权限太多。其中,有一个SUPER特权项。据我所知,所有的名字都是定制的。这是分配权限的屏幕截图。
UPD 1。
我尝试遵循本指南:https ://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/
我有本地安装,对我来说,不清楚任何操作的正确端点是什么。
例如,我可以提出以下要求:
https://d365bc.vendor.com:7057/attain/WS/CRONUS%20International%20Ltd/Page/Customer
结果,我得到了一些计划,但没有客户,或者与他们采取任何行动的可能性。
据我了解,本指南仅提供云安装示例。
Extension APIs:
https://<base URL>:<port>/<serverinstance>/api/<API publisher>/<API group>/<API version>
我做的一切正确吗?这些参数是什么意思?指南中没有提供任何解释。
更新.2
关于要求:必须在 Business Central 服务器实例上启用 API:
所以端口是 7057,API URL 是https://d365bc.vendor.com:7057/Attain/WS/
什么是WS,真的需要吗?通过上面的 URL,我得到了这个:
用于身份验证的用户必须具有 Web 服务访问密钥(在 Business Central 中为用户创建)
这部分没有任何内容,我添加了新密钥。现在它看起来像这样。但这并没有改变我的情况。仍然相同的错误:端口 7057 为 405,端口 7058 为 404。
ps 简单生成就够了吗?或者我们需要在某个地方使用它?
用户必须在 Business Central 中拥有相关 API 所需的权限。
是在下一页管理吗?
以下是响应示例:
网址在域名中使用正确的供应商名称执行后已更改。