I'm working with a third party web service and am having problems sending data from my .Net application. Scenario:
I connect to their server using HttpClient. I get back a security token that gets appended to the end of the request, which is also send using HttpClient.
Here's an update statement that gets sent to the server:
<?xml version="1.0" encoding="utf-8" ?>
<NODES_OPERATIONS>
<ChangeNode URL="C294785" >
<ChangeAttribute Id="bdMarketingShortDescription" Type="string" Value="LW short" />
</ChangeNode>
</NODES_OPERATIONS>
This statement works fine. However, I need to put HTML in the Value attribute, like this: need to send the following:
<?xml version="1.0" encoding="utf-8" ?>
<NODES_OPERATIONS>
<ChangeNode URL="C294785" >
<ChangeAttribute Id="bdMarketingShortDescription" Type="string" Value="<div>LW short</div>" />
</ChangeNode>
</NODES_OPERATIONS>
but I have to HTML encode the Value, so it ends up looking like this:
<NODES_OPERATIONS>
<ChangeNode URL="C294785" >
<ChangeAttribute Id="bdMarketingShortDescription" Type="string" Value="<div>LW short</div>" />
</ChangeNode>
</NODES_OPERATIONS>
There could be one or many ChangeAttributes. I'm am building this using a string builder.
Any type of HTML, either encoded or not, throws an error that the XML can't be parsed. The third party service is written in Java and they don't know what the issue is. They DO support HTML in the value.
The only thing I can come up with here is that the .Net string is UTF 16, not UTF 8, but I'm not sure how to convert this as it works fine when Value is a simple string, but not when it's HTML encoded. Any ideas on what to do here?