RestClient.NewSecure JSON payload with XML field

Hi

I'm trying to call a an HTTPS rest endpoint from oScript using RestClient.NewSecure. Due to historic reasons, I need to post some xml data, but it it embedded in the json payload as a json field.

I build the xml from mostly attribute values - OK.

I build the json string:

					String cSiebelMessage = Str.CString(siebelMessage)
					String jsonPayload = '{'
					jsonPayload += '"body":{'
					jsonPayload += '"Component":"WfProcMgr",'
					jsonPayload += '"Mode":"Sync",'
					jsonPayload += '"Method":"RunProcess",'
					jsonPayload += '"WfParams": {'
					jsonPayload += '"ProcessName":' + '"' + .GetPreferences().Siebel_Workflow_Name + '",' 
					jsonPayload += '"' + .GetPreferences().Siebel_Payload_Field_Name + '": ' + cSiebelMessage + ''
					jsonPayload += '}'
					jsonPayload += '}'
					jsonPayload += '}'

So I've used Str.CString to convert the xml to a C string and escape the double quotes:

"<?xml version=\"1.0\" encoding=\"UTF-16\" ?>........."

the problem is that when this is posted through the client, it looks like it escapes all the '\' again, so it posts:

"IncomingXML": "<?xml version=\\"1.0\\" encoding=\\"UTF-16\\" ?><......."

If I don't use the Str.CString, then I don't get the double quotes escaped, making the json invalid.

any ideas please on how to make the xml then json strings, then post the json (with the xml in it) to the target?

thanks

Guy.

Tagged: