I am using WEB API to POST the content of a XML file by passing the whole content as a string. However I am getting error and now I am trying to find out how I should pass this XML string? escape slashes, no double quotes, etc....
Here is a small example of my (incorrect) JSON structure:
{"xml":"
<server>
<networkAdapters>
<networkAdapter id="3d9c0d9d-d353-4d78-b034-b29f2dd824a0" ipEnabled="true">
<defaultGateways>
<defaultGateway address="x.x.x.x" costMetric="20" index="0" />
</defaultGateways>
<ipAddresses>
<ipAddress address="x.x.x.x" subnetMask="255.255.255.192" index="0" />
</ipAddresses>
<dnsServers>
<dnsServer address="x.x.x.x" index="0" />
<dnsServer address="x.x.x.x" index="1" />
</dnsServers>
</networkAdapter>
</server>"}
WEB API code:
//POST api/RunningValue_Import
public object PostRunningValue(param_RunningValue inputData)
{
try
{
#region Retrieve XML string and Create XDocument
TextReader tr = new StringReader(inputData.xml);
XDocument doc = XDocument.Load(tr);
#endregion
...
I am trying to find out what needs to be done before I POST the whole XML content to my WEB API.
Any ideas? Thank you