gpt4 book ai didi

json - Sage 50 SData XML 到 JSON POST 请求

转载 作者:行者123 更新时间:2023-12-03 23:06:41 29 4
gpt4 key购买 nike

我的最终目标是使用 SData 和 Python 请求将订单从 csv 推送到 Sage 50。

我找到了一个 XML 正文模式的 sippet(见下文),以使用 SData 构建销售订单并将其推送到 Sage 50。我已经成功地通过使用 Python 请求使用此代码段推送销售订单 POST .

我已阅读 Documentation还有这个link您可以使用 JSON 与 SData 交互,这在 Python 中更可取,添加 ?format=json到 URL 的末尾。我已经能够使用 GET请求并使其返回 JSON 响应,但是,我不确定如何更改 POST 的正文从 XML 到 JSON 的销售订单请求。

我做了 GET请求 http://xxxxxx/sdata/accounts50/GCRM/ {xxxxxx}/salesOrders?include=SalesOrderLines&format=json

这为包含订单行的销售订单返回了一个 JSON 结构,所以我尝试使用它来创建我的 JSON POST request 但是每次我提出请求时似乎都会出错。

任何建议都会很棒!

请求的工作 XML 正文:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns="http://www.w3.org/2005/Atom" xmlns:http="http://schemas.sage.com/sdata/http/2008/1" xmlns:sdatasync="http://schemas.sage.com/sdata/sync/2008/1" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:sme="http://schemas.sage.com/sdata/sme/2007" xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<author />
<sdata:payload>
<salesOrder xmlns="http://schemas.sage.com/crmErp/2008">
<active xsi:nil="true" />
<reference xsi:nil="true" />
<reference2 xsi:nil="true" />
<status xsi:nil="true" />
<allocationStatus xsi:nil="true" />
<deliveryStatus xsi:nil="true" />
<invoiceStatus xsi:nil="true" />
<statusFlag xsi:nil="true" />
<statusFlagText xsi:nil="true" />
<tradingAccount sdata:url="http://xxxxx/sdata/accounts50/GCRM/{xxxxxxxxxxx}/tradingAccountCustomer(xxxxxxx)?format=atomentry" sdata:uuid="xxxxxxxxxx">
</tradingAccount>
<customerReference xsi:nil="true" />
<opportunity xsi:nil="true" />
<pricelist xsi:nil="true" />
<supplierTradingAccount xsi:nil="true" />
<supplierReference xsi:nil="true" />
<supplierPurchaseOrders xsi:nil="true" />
<type xsi:nil="true" />
<copyFlag xsi:nil="true" />
<originatorDocument xsi:nil="true" />
<quotation xsi:nil="true" />
<postalAddresses xsi:nil="true" />
<deliveryMethod xsi:nil="true" />
<deliveryRule xsi:nil="true" />
<deliveryTerms xsi:nil="true" />
<deliveryDate xsi:nil="true" />
<dueDate xsi:nil="true" />
<carrierCompany xsi:nil="true" />
<carrierTradingAccount xsi:nil="true" />
<carrierNetPrice xsi:nil="true" />
<carrierTaxPrice xsi:nil="true" />
<carrierTotalPrice xsi:nil="true" />
<carrierSalesInvoice xsi:nil="true" />
<carrierTaxCodes xsi:nil="true" />
<carrierReference xsi:nil="true" />
<currency xsi:nil="true" />
<operatingCompanyCurrency xsi:nil="true" />
<operatingCompanyCurrencyExchangeRate xsi:nil="true" />
<operatingCompanyCurrencyExchangeRateOperator xsi:nil="true" />
<operatingCompanyCurrencyExchangeRateDate xsi:nil="true" />
<invoiceCurrency xsi:nil="true" />
<invoiceCurrencyExchangeRate xsi:nil="true" />
<invoiceCurrencyExchangeRateOperator xsi:nil="true" />
<invoiceCurrencyExchangeRateDate xsi:nil="true" />
<customerTradingAccountCurrency xsi:nil="true" />
<customerTradingAccountCurrencyExchangeRate xsi:nil="true" />
<customerTradingAccountCurrencyExchangeRateOperator xsi:nil="true" />
<customerTradingAccountCurrencyExchangeRateDate xsi:nil="true" />
<date xsi:nil="true" />
<time xsi:nil="true" />
<validity xsi:nil="true" />
<expirationDate xsi:nil="true" />
<taxCodes>
<taxCode>
<notes xsi:nil="true" />
</taxCode>
</taxCodes>
<buyerContact xsi:nil="true" />
<salesPersons xsi:nil="true" />
<user xsi:nil="true" />
<salesOrderLines>
<salesOrderLine>
<salesOrder xsi:nil="true" />
<active xsi:nil="true" />
<reference xsi:nil="true" />
<reference2 xsi:nil="true" />
<number xsi:nil="true" />
<status xsi:nil="true" />
<type>Standard</type>
<deliveryTerms xsi:nil="true" />
<commodity>
</commodity>
<text xsi:nil="true" />
<associatedCommodity xsi:nil="true" />
<fulfillmentLocation xsi:nil="true" />
<deliveryDate xsi:nil="true" />
<dueDate xsi:nil="true" />
<carrierTradingAccount xsi:nil="true" />
<carrierNetPrice xsi:nil="true" />
<carrierTaxPrice xsi:nil="true" />
<carrierTotalPrice xsi:nil="true" />
<carrierSalesInvoiceLine xsi:nil="true" />
<carrierTaxCodes xsi:nil="true" />
<carrierReference xsi:nil="true" />
<unitOfMeasure xsi:nil="true" />
<quantity>2.00</quantity>
<initialPrice xsi:nil="true" />
<pricelist xsi:nil="true" />
<supplierTradingAccount xsi:nil="true" />
<supplierReference xsi:nil="true" />
<supplierPurchaseOrder xsi:nil="true" />
<supplierPurchaseOrderLine xsi:nil="true" />
<quotationLine xsi:nil="true" />
<postalAddresses xsi:nil="true" />
<orderLineDiscountType xsi:nil="true" />
<orderLineDiscountAmount xsi:nil="true" />
<orderLineDiscountPercent xsi:nil="true" />
<orderLineSubtotalDiscountType xsi:nil="true" />
<orderLineSubtotalDiscountAmount xsi:nil="true" />
<orderLineSubtotalDiscountPercent xsi:nil="true" />
<FOBPoint xsi:nil="true" />
<actualPrice>20.00</actualPrice>
<netTotal>50.00</netTotal>
<chargesTotal xsi:nil="true" />
<discountTotal xsi:nil="true" />
<taxCodes>
<taxCode>
<notes xsi:nil="true" />
</taxCode>
</taxCodes>
<priceTax xsi:nil="true" />
<taxTotal>10.00</taxTotal>
<grossTotal>60.00</grossTotal>
<costTotal xsi:nil="true" />
<profitTotal xsi:nil="true" />
<salesInvoiceLines xsi:nil="true" />
<receipts xsi:nil="true" />
<buyerContact xsi:nil="true" />
<project xsi:nil="true" />
<salesOrderDeliveryLines xsi:nil="true" />
<BOMLine xsi:nil="true" />
<financialAccounts xsi:nil="true" />
</salesOrderLine>
<salesOrderLine>
<salesOrder xsi:nil="true" />
<active xsi:nil="true" />
<reference xsi:nil="true" />
<reference2 xsi:nil="true" />
<number xsi:nil="true" />
<status xsi:nil="true" />
<type>Free Text</type>
<deliveryTerms xsi:nil="true" />
<commodity xsi:nil="true" />
<text>An example product</text>
<associatedCommodity xsi:nil="true" />
<fulfillmentLocation xsi:nil="true" />
<deliveryDate xsi:nil="true" />
<dueDate xsi:nil="true" />
<carrierTradingAccount xsi:nil="true" />
<carrierNetPrice xsi:nil="true" />
<carrierTaxPrice xsi:nil="true" />
<carrierTotalPrice xsi:nil="true" />
<carrierSalesInvoiceLine xsi:nil="true" />
<carrierTaxCodes xsi:nil="true" />
<carrierReference xsi:nil="true" />
<unitOfMeasure xsi:nil="true" />
<quantity>5.00</quantity>
<initialPrice xsi:nil="true" />
<pricelist xsi:nil="true" />
<supplierTradingAccount xsi:nil="true" />
<supplierReference xsi:nil="true" />
<supplierPurchaseOrder xsi:nil="true" />
<supplierPurchaseOrderLine xsi:nil="true" />
<quotationLine xsi:nil="true" />
<postalAddresses xsi:nil="true" />
<orderLineDiscountType xsi:nil="true" />
<orderLineDiscountAmount xsi:nil="true" />
<orderLineDiscountPercent xsi:nil="true" />
<orderLineSubtotalDiscountType xsi:nil="true" />
<orderLineSubtotalDiscountAmount xsi:nil="true" />
<orderLineSubtotalDiscountPercent xsi:nil="true" />
<FOBPoint xsi:nil="true" />
<actualPrice xsi:nil="true" />
<netTotal>100.00</netTotal>
<chargesTotal xsi:nil="true" />
<discountTotal xsi:nil="true" />
<taxCodes>
<taxCode>
<notes xsi:nil="true" />
</taxCode>
</taxCodes>
<priceTax xsi:nil="true" />
<taxTotal>20.00</taxTotal>
<grossTotal>120.00</grossTotal>
<costTotal xsi:nil="true" />
<profitTotal xsi:nil="true" />
<salesInvoiceLines xsi:nil="true" />
<receipts xsi:nil="true" />
<buyerContact xsi:nil="true" />
<project xsi:nil="true" />
<salesOrderDeliveryLines xsi:nil="true" />
<BOMLine xsi:nil="true" />
<financialAccounts xsi:nil="true" />
</salesOrderLine>
</salesOrderLines>
<lineCount xsi:nil="true" />
<orderDiscountType xsi:nil="true" />
<orderDiscountAmount xsi:nil="true" />
<orderDiscountPercent xsi:nil="true" />
<orderAdditionalDiscount1Type xsi:nil="true" />
<orderAdditionalDiscount1Amount xsi:nil="true" />
<orderAdditionalDiscount1Percent xsi:nil="true" />
<orderAdditionalDiscount2 xsi:nil="true" />
<orderAdditionalDiscount2Amount xsi:nil="true" />
<orderAdditionalDiscount2Percent xsi:nil="true" />
<text1 xsi:nil="true" />
<text2 xsi:nil="true" />
<netTotal xsi:nil="true" />
<discountTotal xsi:nil="true" />
<chargesTotal xsi:nil="true" />
<taxTotal xsi:nil="true" />
<grossTotal xsi:nil="true" />
<costTotal xsi:nil="true" />
<profitTotal xsi:nil="true" />
<receipts xsi:nil="true" />
<depositFlag xsi:nil="true" />
<contract xsi:nil="true" />
<invoiceTradingAccount xsi:nil="true" />
<invoiceCountry xsi:nil="true" />
<orderCountry xsi:nil="true" />
<projects xsi:nil="true" />
<salesOrderDeliveries xsi:nil="true" />
<fulfillmentLocations xsi:nil="true" />
<financialAccounts xsi:nil="true" />
<interactions xsi:nil="true" />
<notes xsi:nil="true" />
</salesOrder>
</sdata:payload>
</entry>

尝试转换为 JSON 失败:
{
"$descriptor": "Sage Accounts 50 | salesOrder",
"$url": "http://xxxxxx/sdata/accounts50/GCRM/{xxxxxxxxxx}/salesOrders",
"$resources": [
{
"active": true,
"reference": "1",
"reference2": "",
"status": "In Progress",
"allocationStatus": "Full",
"deliveryStatus": "",
"invoiceStatus": "",
"statusFlag": null,
"statusFlagText": null,
"tradingAccount": null,
"customerReference": "",
"opportunity": null,
"pricelist": null,
"supplierTradingAccount": null,
"supplierReference": null,
"supplierPurchaseOrders": null,
"type": "Sales Order",
"copyFlag": false,
"originatorDocument": null,
"quotation": null,
"postalAddresses": null,
"deliveryMethod": null,
"deliveryRule": null,
"deliveryTerms": null,
"deliveryDate": null,
"dueDate": null,
"carrierCompany": null,
"carrierTradingAccount": null,
"carrierNetPrice": 0.0,
"carrierTaxPrice": 0.0,
"carrierTotalPrice": 0.0,
"carrierSalesInvoice": null,
"carrierTaxCodes": null,
"carrierReference": "",
"currency": "GBP",
"operatingCompanyCurrency": "GBP",
"operatingCompanyCurrencyExchangeRate": 1.0,
"operatingCompanyCurrencyExchangeRateOperator": "/",
"operatingCompanyCurrencyExchangeRateDate": null,
"invoiceCurrency": null,
"invoiceCurrencyExchangeRate": null,
"invoiceCurrencyExchangeRateOperator": null,
"invoiceCurrencyExchangeRateDate": null,
"customerTradingAccountCurrency": null,
"customerTradingAccountCurrencyExchangeRate": null,
"customerTradingAccountCurrencyExchangeRateOperator": null,
"customerTradingAccountCurrencyExchangeRateDate": null,
"date": null,
"time": null,
"validity": null,
"expirationDate": null,
"taxCodes": null,
"buyerContact": null,
"salesPersons": null,
"user": "MANAGER",
"salesOrderLines": {
"$url": "http://xxxxxxxxxxx/sdata/accounts50/GCRM/{xxxxxxxxxxxxxx}/SalesOrderLines",
"$resources": [
{
"salesOrder": null,
"active": true,
"reference": "1",
"reference2": "",
"number": 1.0,
"status": null,
"type": "0",
"deliveryTerms": null,
"commodity": null,
"text": "kll",
"associatedCommodity": null,
"fulfillmentLocation": null,
"deliveryDate": null,
"dueDate": null,
"carrierTradingAccount": null,
"carrierNetPrice": null,
"carrierTaxPrice": null,
"carrierTotalPrice": null,
"carrierSalesInvoiceLine": null,
"carrierTaxCodes": null,
"carrierReference": "",
"unitOfMeasure": null,
"quantity": 1.0,
"initialPrice": 1.0,
"pricelist": null,
"supplierTradingAccount": null,
"supplierReference": null,
"supplierPurchaseOrder": null,
"supplierPurchaseOrderLine": null,
"quotationLine": null,
"postalAddresses": null,
"orderLineDiscountType": null,
"orderLineDiscountAmount": 0.0,
"orderLineDiscountPercent": 0.0,
"orderLineSubtotalDiscountType": null,
"orderLineSubtotalDiscountAmount": null,
"orderLineSubtotalDiscountPercent": null,
"FOBPoint": null,
"actualPrice": 1.0,
"netTotal": 1.0,
"chargesTotal": null,
"discountTotal": 0.0,
"taxCodes": null,
"priceTax": null,
"taxTotal": 0.0,
"grossTotal": 1.0,
"costTotal": null,
"profitTotal": null,
"salesInvoiceLines": null,
"receipts": null,
"buyerContact": null,
"project": null,
"salesOrderDeliveryLines": null,
"BOMLine": null,
"financialAccounts": null
}
]
},
"lineCount": 1.0,
"orderDiscountType": null,
"orderDiscountAmount": 0.0,
"orderDiscountPercent": 0.0,
"orderAdditionalDiscount1Type": null,
"orderAdditionalDiscount1Amount": null,
"orderAdditionalDiscount1Percent": null,
"orderAdditionalDiscount2": null,
"orderAdditionalDiscount2Amount": null,
"orderAdditionalDiscount2Percent": null,
"text1": "",
"text2": "",
"netTotal": 1.0,
"discountTotal": null,
"chargesTotal": null,
"taxTotal": 0.0,
"grossTotal": 1.0,
"costTotal": null,
"profitTotal": null,
"receipts": null,
"depositFlag": null,
"contract": null,
"invoiceTradingAccount": null,
"invoiceCountry": null,
"orderCountry": null,
"projects": null,
"salesOrderDeliveries": null,
"fulfillmentLocations": null,
"financialAccounts": null,
"interactions": null,
"notes": null,
"CustomerId": "xxxxxxxxxxxxxx"
}]}

最佳答案

您发布的文档链接适用于 Sdata 2.0,但不幸的是,Sage 50 Accounts Sdata 适配器仅支持 Sdata 1.0/1.1。这意味着它不支持使用 JSON 的 POST/PUT,您只能将 XML 用于这些操作。

关于json - Sage 50 SData XML 到 JSON POST 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62161890/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com