Custom method - return Json Array

Hoping someone has more experience with this and can point me in the right direction.

Have a custom method that goes and gets data from Salesforce via REST API. The response comes back and I want to return the "records" array back to front end for display.

JObject obj = JObject.Parse(data);
System.Console.WriteLine(obj["records"].ToString());

This is the output to the console;
"[
{
"attributes": {
"type": "Account",
"url": "/services/data/v52.0/sobjects/Account/Id"
},
"Id": "0016xxxxxxxxxx",
"Name": "xxxxxx",
"BillingStreet": "xxxxxxx"
}
]"

Not really sure how to return this, everything I try the datagrid does not recognize the variable set with the result.

Tried many different variations;
return Json(new { value = obj["records"] }, new JsonSerializerSettings() {
ContractResolver = new DefaultContractResolver()
});

Any thoughts on what I'm doing wrong. I set a variable to ${result.value} but doesn't show for binding to datagrid.

Thanks,

Hi @DAGamer,

Check what’s returned using your browser developer tools network tab.

The json coming back is as follows;

image

In this case you can simply use ${result}, there is no value property in the response.

image

The property won't show for binding;
image

I'll try adding a name to the array, value: [...]

Click the chain link next to Data property and choose the page property where ${result} is assigned.

Thanks for the help - its working by manually adding the data property and columns ${data.Name}, etc..