Open Szandor72 opened 7 years ago
Hmmm not sure, would not expect so, can you run this from anonymous apex prompt and capture the actual REST response, this will help determine if its a marshalling issue or not.
This is the REST response:
{
"size":1,
"totalSize":1,
"done":true,
"queryLocator":null,
"entityTypeName":"ApexClass",
"records":[
{
"attributes":{
"type":"ApexClass",
"url":"/services/data/v38.0/tooling/sobjects/ApexClass/01pA0000001AF1eIAG"
},
"Id":"01pA0000001AF1eIAG",
"Name":"MultiAttachment",
"SymbolTable":{
"constructors":[
{
"annotations":[
],
"location":{
"column":9,
"line":11
},
"modifiers":[
"public"
],
"name":"MultiAttachment",
"parameters":[
],
"references":[
],
"type":null
}
],
"externalReferences":[
],
"id":"01pA0000001AF1eIAG",
"innerClasses":[
],
"interfaces":[
],
"key":"01pA0000001AF1eIAG",
"methods":[
{
"annotations":[
],
"location":{
"column":29,
"line":18
},
"modifiers":[
"public"
],
"name":"getAttachments",
"parameters":[
],
"references":[
],
"returnType":"LIST",
"type":null
},
{
"annotations":[
],
"location":{
"column":14,
"line":27
},
"modifiers":[
"public"
],
"name":"addMore",
"parameters":[
],
"references":[
],
"returnType":"void",
"type":null
},
{
"annotations":[
],
"location":{
"column":14,
"line":35
},
"modifiers":[
"public"
],
"name":"saveAttachment",
"parameters":[
],
"references":[
],
"returnType":"void",
"type":null
},
{
"annotations":[
],
"location":{
"column":14,
"line":51
},
"modifiers":[
"public"
],
"name":"deleteAttachment",
"parameters":[
],
"references":[
],
"returnType":"void",
"type":null
},
{
"annotations":[
],
"location":{
"column":23,
"line":59
},
"modifiers":[
"public"
],
"name":"done",
"parameters":[
],
"references":[
],
"returnType":"PageReference",
"type":null
}
],
"name":"MultiAttachment",
"namespace":"ss33a",
"parentClass":"",
"properties":[
{
"annotations":[
],
"location":{
"column":12,
"line":2
},
"modifiers":[
"public"
],
"name":"sobjId",
"references":[
],
"type":"Id"
},
{
"annotations":[
],
"location":{
"column":26,
"line":3
},
"modifiers":[
"public"
],
"name":"attachments",
"references":[
],
"type":"LIST"
},
{
"annotations":[
],
"location":{
"column":26,
"line":4
},
"modifiers":[
"public"
],
"name":"newAttachments",
"references":[
],
"type":"LIST"
},
{
"annotations":[
],
"location":{
"column":12,
"line":6
},
"modifiers":[
"public"
],
"name":"idAttachmentDelete",
"references":[
],
"type":"Id"
},
{
"annotations":[
],
"location":{
"column":30,
"line":5
},
"modifiers":[
"static",
"public",
"final"
],
"name":"NUM_ATTACHMENTS_TO_ADD",
"references":[
],
"type":"Integer"
}
],
"tableDeclaration":{
"annotations":[
],
"location":{
"column":30,
"line":1
},
"modifiers":[
"public",
"without sharing"
],
"name":"MultiAttachment",
"references":[
],
"type":"MultiAttachment"
},
"variables":[
{
"annotations":[
],
"location":{
"column":16,
"line":29
},
"modifiers":[
],
"name":"idx",
"references":[
],
"type":"Integer"
},
{
"annotations":[
],
"location":{
"column":20,
"line":36
},
"modifiers":[
],
"name":"toInsert",
"references":[
],
"type":"LIST"
},
{
"annotations":[
],
"location":{
"column":19,
"line":37
},
"modifiers":[
],
"name":"newAtt",
"references":[
],
"type":"Attachment"
},
{
"annotations":[
],
"location":{
"column":20,
"line":52
},
"modifiers":[
],
"name":"lstAttDelete",
"references":[
],
"type":"LIST"
}
]
}
}
]
}
the parsed queryresult returns for symbols
VisibilitySymbol:[Symbol.location=Position:[column=26, line=3], Symbol.modifiers=(public), Symbol.name=attachments, Symbol.references=(), Symbol.type_x=null, visibility=null]
_Symbol.typx=null instead of "type":"LIST" as in the above response
Ok so it is present in the response, and thus the problem is in the deserialisation from JSON to Apex. What I think i see is going on is this.
Since "type" is reserved word in Apex, it cannot be used as a variable name. When using the XML serialiser and deserialiser < type >xxxx< /type > gets automatically mapped to variables named "type_x" to work around this. Hence this might work ok for XML/SOAP version of the API (see main branch) but it looks like the JSON serialiser and deserialiser may not honour this convention.
So i did a bit of googling and found this. Which provides two possible solutions to this problem. The find/replace solution while simple might cause a performance impact depending on how many callouts your making i guess. So if your using the REST API, you could problem insert a line to do the find and replace in this method to try it. Let me know how it goes!
P.S. Sorry for the late reply, been a bit busy with moving and holiday time.
Happy new year Andrew, no worries!
thanks for your update, I'll report back asap.
Hey,
when retrieving ApeClasses with their Symbol Tables via
ToolingAPI.QueryResult qr = toolingApi.query('Select id,name, SymbolTable from ApexClass limit 1');
and looping through results, to retrieve properties and variables, I always get Type = null
Is that a known limitation of the REST version?