I have created a custom connector to make a post request to our REST Service that returns an array of objects nested in another object. My goal is to work with object.Data.Data.
{
"User": "55205bb2-28c4-ed11-83ff-0022489ede2f",
"ErrorMessage": null,
"Data": "{\"TotalRecordCount\":1,\"TotalRecordExcluded\":0,\"Data\":[{\"Id\":\"13a0293d-c7de-ed11-a7c6-0022489ede2f\",\"Name\":\"Second trial!\",\"FileName\":\"Another File Name\",\"TotalRows\":14,\"IsProcessed\":false,\"Date\":\"2023-04-17T22:00:00Z\",\"ExpectedFileDate\":\"2023-04-03T22:00:00Z\",\"IsCompleted\":false,\"ErrorMessages\":null,\"Excluded\":false,\"LogicalName\":\"eps_datacollectionfile\"}]}"
}
This is the method in the service called:
try
{
Log.Debug($@"X-Correlation-ID {CorrelationId} - START: GetMultipleFileInfo- ids {ids}");
List<MsdDataCollectionFile> fileinfo = GetMultipleFileInfoData(ids);
dynamic paged = new ExpandoObject();
paged.TotalRecordCount = fileinfo.Count;
paged.TotalRecordExcluded = fileinfo.Where(x => x.Excluded).Count();
paged.Data = fileinfo;
Log.Debug($@"X-Correlation-ID {CorrelationId} - END: GetMultipleFileInfoData- totalrecord {fileinfo.Count}");
return new HttpResponse(((System.Dynamic.ExpandoObject)paged).ToJSON(), null);
}
I call it in a custom app creating a collection passing the parameters it expects (with
ClearCollect(connectorCollection, DataCollection.GetFile(userId, "application/json", {body:"13a0293d-c7de-ed11-a7c6-0022489ede2f"}).Data.Data))
It seems ok because the gallery in Canva gets correctly the data model. image: Canvas editor
However, when launched from the model-driven app, it doesn't work, saying, "JSON parsing error, expected 'object' but got 'string'." image: DevTools
Does anyone of you have any idea on what I can fix in the parsing?
I was trying to fetch an object from a Canvas App through a Custom Connector, and expecting to be able to read the object.