我在访问Zoho inventory的api时遇到了一点麻烦,它有一个数据数组,这是它的外观
{
"date": "2015-05-28",
"reason": "Damaged goods",
"description": "Just a sample description.",
"reference_number": "REF-IA-00001",
"adjustment_type": "quantity",
"line_items": [
{
"item_id": 4815000000044100,
"name": "Laptop-white/15inch/dell",
"description": "Just a sample description.",
"quantity_adjusted": 10,
"item_total": 244,
"unit": "qty",
"is_combo_product": false,
"adjustment_account_id": 4815000000000388,
"adjustment_account_name": "Cost of Goods Sold",
"warehouse_id": 4815000000000390,
"warehouse_name": "MyWarehouse"
}
]
}
这是我当前的代码
headersMap = Map();
headersMap.put("Authorization","Zoho-oauthtoken xxxxxxxxxxxxxxxxx");
parametersMap = Map();
response = invokeurl
[
url :"https://inventory.zoho.com/api/v1/inventoryadjustments?organization_id=xxxx"
type :POST
headers:headersMap
];
dateVal = input.Date_field;
reasonVal = input.Reason;
descriptionVal = input.Description1;
referenceNumberVal = input.Reference_Number;
adjustmentTypeVal = input.Adjustment_Type;
itemIDVal = input.Item_ID;
nameVal = input.Name1;
quantityAdjustedVal = input.Quantity_Adjusted;
itemTotalVal = input.Item_Total;
unitVal = input.Unit;
isComboProductVal = input.Is_Combo_Product;
adjustmentAccountIdVal = input.Adjustment_Account_ID;
adjustmentAccountNameVal = input.Adjustment_Account_Name;
warehouseIdVal = input.Warehouse_ID;
warehouseNameVal = input.Warehouse_Name;
parametersMap.put("date",dateVal);
parametersMap.put("reason",reasonVal);
parametersMap.put("description",descriptionVal);
parametersMap.put("reference_number",referenceNumberVal);
parametersMap.put("adjustment_type",adjustmentTypeVal);
我已经为所有的值创建了变量,但是我对如何写“line_items”数组的键有点困惑,任何关于这方面的帮助都将非常感谢。
1条答案
按热度按时间wfveoks01#
修订版2:
1.“line_items”看起来像是“对映清单”。每个项目有一个“对映”。范例中的“line_item”特定程式码在注解中有“Line_Items:“信头。
1.似乎应在调用invokeurl之前设置parameterMap。
然后invokeurl应该包含parameterMap。
示例: