I'm attempting to create a test framework in c# to automate some of our API tests. Relatively new to this area so have come across an issue I can't solve. My XML payload is as below:
<Order>
<BillingAddress>
<AddressLine1></AddressLine1>
<AddressLine2></AddressLine2>
<City></City>
</BillingAddress>
<Items>
<Item IsKit="false">
<CountryVATRate></CountryVATRate>
<Group></Group>
<Reference></Reference>
</Item>
</Items>
</Order>
When I attempt to execute the above(using RestSharp) I get the below error: "System.Xml.XmlException: 'The ' ' character, hexadecimal value 0x20, cannot be included in a name.'"
The offending line of code is
<Item IsKit="false">
...where the code in c# I have written is as below
XElement items = new XElement("Items");
items.Add(new XElement("Item IsKit =\"false\""
I believe the issue is because there are spaces between the words 'Item' and 'IsKit'....my question is how I would get around this in order for this element to be added to my test code?
Items
tag is not closed and might be causing the issue.