You need to sign in to do that
Don't have an account?
Circular Object Graph detected
Hi All, I have a webservice written in APEX which returns a complex object. This complext object is a List of Object which itself has another list of object. we can say 2D arrays.
While i am trying to consume it from a Java client it throws this error:
"Circular Object Graph detected during serialization, you can not have circular object references in an Apex WebService response."
My class is:
global class SampleService { global class ObjectFieldInformation { WebService Integer fieldSerialNumber; } global class ObjectInformation { WebService List<ObjectFieldInformation> objectFieldInformationList; } global class CallsResponse { WebService List<ObjectInformation> callList; WebService String something; } WebService static CallsResponse getComplexObjects() { FindCallsResponse response = new FindCallsResponse(); List<ObjectInformation> responseCallList = new List<ObjectInformation>(); ObjectFieldInformation objResultFieldInfo; ObjectInformation objCallInfo = new ObjectInformation(); for(Integer i=0;i<5;i++) { List<ObjectFieldInformation> callData = new List<ObjectFieldInformation>(); for(Integer j=0;j<5;j++) { objResultFieldInfo = new ObjectFieldInformation(); callData.add(objResultFieldInfo); } objCallInfo.objectFieldInformationList = callData; responseCallList.add(objCallInfo); } response.callList = responseCallList; return response; } }
Please advise.
/G
You have the same instance of objcallInfo inserted into the responseCallList array multiple times.
All Answers
You have the same instance of objcallInfo inserted into the responseCallList array multiple times.
It worked Simon, Thank a lot.
Hi All,
I have the same error in a, Apex webservice I developed. Can you show us what did you change in your code to fix this issue?
Thanks,
Olivier Spehner
It's an ugly workaround, but you can call .clone() on the objects before you return them.
Putting the same object into a list twice really shouldn't be a crime, and clearly is not a "circular" reference.