0

我正在尝试使用 Navision OData RESTful Web 服务来执行 CRUD 操作,但我在 PUT 操作中遇到了困难。

{
"@odata.context": "http://192.168.0.10:1148/DynamicsNAV100/ODataV4/$metadata#Collection(NAV.Customer2)",
"@odata.etag": "W/\"JzUyO0VnQUFBQUo3RGpNQU1nQXpBRE1BTWdBeUFESUFNd0F5QURNQU13QXlBRE1BTndBQUFBQUE2OzY1NTU0MDA7Jw==\"",
"No": "32332223233237",
"Name": "Progressive Home Furnishings",
"Search_Name": "PROGRESSIVE HOME FURNISHINGS",
"IC_Partner_Code": "",
"Balance_LCY": 0,
"Balance_Due_LCY": 0,
"Credit_Limit_LCY": 0,
"Blocked": " ",
"Salesperson_Code": "JR",
"Responsibility_Center": "",
"Service_Zone_Code": "X",
"BlockedCustomer": false,
"Document_Sending_Profile": "",
"TotalSales2": 0,
"CustSalesLCY_CustProfit_AdjmtCostLCY": 0,
"AdjCustProfit": 0,
"AdjProfitPct": 0,
"Language_Code": "ENU",
"Last_Date_Modified": "2017-10-28T00:00:00Z",
"Address": "3000 Roosevelt Blvd.",
"Address_2": "",
"Post_Code": "US-IL 61236",
"City": "Chicago",
"Country_Region_Code": "US",
"ShowMap": "Show on Map",
"Primary_Contact_No": "",
"ContactName": "",
"Phone_No": "",
"E_Mail": "",
"Fax_No": "",
"Home_Page": "",
"Bill_to_Customer_No": "",
"VAT_Registration_No": "",
"GLN": "",
"Copy_Sell_to_Addr_to_Qte_From": "Company",
"Gen_Bus_Posting_Group": "EXPORT",
"VAT_Bus_Posting_Group": "EXPORT",
"Customer_Posting_Group": "FOREIGN",
"Invoice_Copies": 0,
"Currency_Code": "USD",
"Customer_Price_Group": "",
"Customer_Disc_Group": "RETAIL",
"Allow_Line_Disc": true,
"Invoice_Disc_Code": "01445544",
"Prices_Including_VAT": false,
"Prepayment_Percent": 0,
"Application_Method": "Manual",
"Partner_Type": " ",
"Payment_Terms_Code": "14 DAYS",
"Payment_Method_Code": "",
"Reminder_Terms_Code": "FOREIGN",
"Fin_Charge_Terms_Code": "2.0 FOR.",
"Cash_Flow_Payment_Terms_Code": "",
"Print_Statements": true,
"Last_Statement_No": 0,
"Block_Payment_Tolerance": false,
"Preferred_Bank_Account_Code": "",
"Location_Code": "YELLOW",
"Combine_Shipments": true,
"Reserve": "Optional",
"Shipping_Advice": "Partial",
"Shipment_Method_Code": "EXW",
"Shipping_Agent_Code": "",
"Shipping_Agent_Service_Code": "",
"Shipping_Time": "",
"Base_Calendar_Code": "",
"Customized_Calendar": "No",
"GetMoneyOwedExpected": 0,
"TotalMoneyOwed": 0,
"CalcCreditLimitLCYExpendedPct": 0,
"Balance_Due": 0,
"Payments_LCY": 0,
"CustomerMgt_AvgDaysToPay_No": 0,
"DaysPaidPastDueDate": 0,
"GetAmountOnPostedInvoices": 0,
"GetAmountOnCrMemo": 0,
"GetAmountOnOutstandingInvoices": 0,
"GetAmountOnOutstandingCrMemos": 0,
"Totals": 0,
"CustInvDiscAmountLCY": 0,
"Global_Dimension_1_Filter": "",
"Global_Dimension_2_Filter": "",
"Currency_Filter": "",
"Date_Filter": "01/01/17..12/31/17",
"ETag": "52;EgAAAAJ7DjMAMgAzADMAMgAyADIAMwAyADMAMwAyADMANwAAAAAA6;6555400;"}

对于这个对象,我正在调用:-

http://192.168.0.10:1148/DynamicsNAV100/ODataV4/Company('testcomp')/Customer2('32332223233237')

with `header if-match as W/"'52;EgAAAAJ7DjMAMgAzADMAMgAyADIAMwAyADMAMwAyADMANwAAAAAA6;6555400;'"`

但我要么得到

请传递并发令牌

或者

输入不是有效的 base64 字符串。

错误的原因是什么?我是 Navision 的新手

4

2 回答 2

0

您没有etag在 header 中发送正确的内容If_Match
在您的情况下,您需要使用该"@odata.etag"值:

"W/\"JzUyO0VnQUFBQUo3RGpNQU1nQXpBRE1BTWdBeUFESUFNd0F5QURNQU13QXlBRE1BTndBQUFBQUE2OzY1NTU0MDA7Jw==\""

于 2017-12-17T18:38:01.413 回答
0

对于旧版本的 NAV,将公司名称指定为查询参数,例如http://junit:7058/DynamicsNAV80/OData/FundRequestLine(LineNo=4,DocumentNo=3)?company=My+Wonderful+Company+Limited&%24format=json

此外,请确保您在if-match标题中提供的 Etag 采用以下格式:W/"'kljkljf'". 例如:W/"'24;7mkQAwCHAwAAAACHBAAAAAAA9;7257127720;'"当您将其字符串化为 JSON 时,它将如下所示:"W/\"'24;7mkQAwCHAwAAAACHBAAAAAAA9;7257127720;'\""

如果您使用navodata和 navclient npm 库,您的请求正文将如下所示:

{
 "method": "PATCH",
 "etag": "W/\"'24;7mkQAwCHAwAAAACHBAAAAAAA9;7257127720;'\"",
 "query": {
  "serviceName": "FundRequestLine",
  "id": {
   "LineNo": 4,
   "DocumentNo": 3
  }
 }
于 2021-09-01T18:08:21.953 回答