当前位置 : 主页 > 网页制作 > xml >

生成XML文档的Intuit QBO SDK更新Bill错误ItemElementName的值与System.Decimal的类型不匹配

来源:互联网 收集:自由互联 发布时间:2021-06-13
我正在使用Intuit QBO SDK v3 Intuit.Ipp.QueryFilter.QueryService(Of Bill)获取由Bill.Id过滤的Bills集合.该集合已成功填充.我想修改Bill的某些ItemBasedExpenseLineDetail成员的BillableStatus,并使用Intuit.Ipp.DataSe
我正在使用Intuit QBO SDK v3 Intuit.Ipp.QueryFilter.QueryService(Of Bill)获取由Bill.Id过滤的Bills集合.该集合已成功填充.我想修改Bill的某些ItemBasedExpenseLineDetail成员的BillableStatus,并使用Intuit.Ipp.DataService.DataService.Update(Of Bill)更新它.无论我是否实际修改了Bill的任何属性,Update方法都会生成以下错误:

Intuit.Ipp.E​​xception.SerializationException:生成XML文档时出错. —> System.InvalidOperationException:生成XML文档时出错. —> System.InvalidOperationException:ItemElementName的值与System.Decimal的类型不匹配;你需要将它设置为Intuit.Ipp.Data.ItemChoiceType.@ UnitPrice.
   在Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterBill.Write163_ItemBasedExpenseLineDetail(String n,String ns,ItemBasedExpenseLineDetail o,Boolean isNullable,Boolean needType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterBill.Write181_Line(String n,String ns,Line o,Boolean isNullable,Boolean needType)
   在Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterBill.Write185_Bill(String n,String ns,Bill o,Boolean isNullable,Boolean needType)
   在Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterBill.Write186_Bill(Object o)
   —内部异常堆栈跟踪结束—
   在System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,Object o,XmlSerializerNamespaces namespaces,String encodingStyle,String id)
   在System.Xml.Serialization.XmlSerializer.Serialize(Stream stream,Object o,XmlSerializerNamespaces名称空间)
   at Intuit.Ipp.Utility.XmlObjectSerializer.Serialize(Object entity)
   —内部异常堆栈跟踪结束—
   at Intuit.Ipp.Utility.XmlObjectSerializer.Serialize(Object entity)
   at Intuit.Ipp.Core.Rest.RestHandler.PrepareRequest(RequestParameters requestParameters,Object requestBody,String oauthRequestUri)
   在Intuit.Ipp.DataService.DataService.Update [T](T实体)

Bill的所有ItemBasedExpenseLineDetail成员的值似乎正好是Intuit.Ipp.Data.ItemChoiceType.UnitPrice,如Watch或Immediate Window所示,例如:

?DirectCast(qboItem.Line(0).AnyIntuitObject,Intuit.Ipp.Data.ItemBasedExpenseLineDetail).ItemElementName

UnitPrice {2}

任何想法如何执行更新没有此错误或在哪里进一步查看?

Aaaaaand,就在我发布这个问题时,我在Intuit.Developer社区找到了答案

I guess you have the default setting from SDK where request format is XMl and response is Json.

This causes serialization issues which you have mentioned above.

Please add the following lines in your code to have either both request/response in xml or boht in json format.

context.IppConfiguration.Message.Request.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;

context.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;

网友评论