You need to sign in to do that
Don't have an account?
Is there any way to have Apex Rest API return everything in cdata?
So I've created a Rest API like below and I need to have it return all values wrapped in Cdata. Is there an easy way to toggle on cdata? Or do I need to explicitly wrap each field using an xml writer? Even if I pass in cdata values it gets removed on the response due to the deserialization.
Thanks in advance!
@RestResource(urlMapping='/echo/*')
global class echo{
@HttpPost
global static MyClass echo(MyClass c){
return c;
}
global virtual class MyClass{
global String s1;
global String s2;
global String s3;
global String s4;
}
}
Request looks like this
cdata is just a serialization thing, you can serialize the same data without requiring an actual cdata section by encoding as appropriate (which is what the xml tools do), why do you specifically need a cdata section ?
Thanks Simon. I'll look into the xml tools... I need a cdata section as the fields I am going to link up to in SFDC need to support all characters without escaping the xml on the other system.
so the other end is not using an xml parser ??
Simon - yes they are using an xml parser on the other. So they make a request, SF returns the data, the field values need to be contained within the cdata section to allow the XML parser to ignore the content.