web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Problem handling Powerapps Custom Connector response - "JSON parsing error, expected 'object' but got 'string'"

(0) ShareShare
ReportReport
Posted on by
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 the data model correctly.

pastedimage1682600689962v2.png

However, when launched from the model-driven app, it doesn't work, saying, "JSON parsing error, expected 'object' but got 'string'."

pastedimage1682600702644v3.png

pastedimage1682600721077v4.png

Does anyone of you know 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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans