I'm trying to post a cart to the prestashop webservice and I'm getting a deserializer error when trying to get the blank cart. I've red that you get the blank cart from the api (instead of building it from a constructor), then populate it, and finally post it. But when I try to get the blank cart i get the following error:
Microsoft.Bot.Builder.Integration.AspNet.Core.BotFrameworkHttpAdapter:Error: Exception caught : System.InvalidOperationException: There is an error in XML document (4, 11). ---> System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(ReadOnlySpan`1 str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(ReadOnlySpan`1 s, NumberStyles style, NumberFormatInfo info)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderPrestashopCart.Read6_Cart(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderPrestashopCart.Read7_PrestashopCart(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderPrestashopCart.Read8_prestashop()
--- End of inner exception stack trace ---
I've red here that that's due to some tag missing value, but here all the tags have empty values and the error doesn't pop until the 11th line, so I don't know why it means.
The xml:
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<cart>
<id></id>
<id_address_delivery></id_address_delivery>
<id_address_invoice></id_address_invoice>
<id_currency></id_currency>
<id_customer></id_customer>
<id_guest></id_guest>
<id_lang></id_lang>
<id_shop_group></id_shop_group>
<id_shop></id_shop>
<id_carrier></id_carrier>
<recyclable></recyclable>
<gift></gift>
<gift_message></gift_message>
<mobile_theme></mobile_theme>
<delivery_option></delivery_option>
<secure_key></secure_key>
<allow_seperated_package></allow_seperated_package>
<date_add></date_add>
<date_upd></date_upd>
<associations>
<cart_rows>
<cart_row>
<id_product></id_product>
<id_product_attribute></id_product_attribute>
<id_address_delivery></id_address_delivery>
<quantity></quantity>
</cart_row>
</cart_rows>
</associations>
</cart>
</prestashop>
The deserializer class:
[XmlRoot("prestashop")]
public class PrestashopCart
{
[XmlElement("cart")]
public Cart Cart { get; set; }
}
public class Cart : IIdentifiable
{
[XmlElement("id")]
public override int Id { get; set; }
[XmlElement("id_address_delivery")]
public int DeliveryAddressId { get; set; }
[XmlElement("id_address_invoice")]
public int AdressInvoiceId { get; set; }
[XmlIgnore]
public Customer Customer { get; set; }
private int? _customerId { get; set; }
[XmlElement("id_currency")]
public int CurrencyId { get; set; }
[XmlElement("id_customer")]
public int CustomerId
{
get { return _customerId ?? Customer.Id; }
set { _customerId = value; }
}
[XmlElement("id_guest")]
public int GuestId { get; set; }
[XmlElement("id_lang")]
public int LanguageId { get; set; }
[XmlElement("id_shop_group")]
public int? ShopGroupId { get; set; }
[XmlElement("associations")]
public CartRowCollection Rows { get; set; }
}
There's some xml tags missing, that's because I don't need these fields.