Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 9gFNszxtdtkVu2WpsXhWRR
Power Apps - Building Power Apps
Answered

Power App + custom connector + Azure API Management - The Data return in the response is invalid, Response data should be a valid JSON object

Like (2) ShareShare
ReportReport
Posted on 22 Jul 2022 10:13:43 by 40

Hi all,

 

I'd be very grateful for any help here - this error is in the category of Power Apps being 95% fantastic and the final 5% painful frustration.

 

I have a new custom API deployed via Azure API Management for use by our external partners to access data in one of our corporate systems.

 

I'm trying to build a Power App front end to allow some of our internal staff to test the data it returns as part of our test process before releasing to external partners.

 

There are 11 operations in the API. All are simple GETs.

 

When I create custom connector with a new connection and try to call the API from a canvas Power App, I get the message in the Power App: "The Data return in the response is invalid, Response data should be a valid JSON object".      I've looked at other forum messages with the same error and can't see any solution to my problem.

 

Everything else about using the API looks fine:

- I can test operations from the Azure Management dev portal "Try It" feature with no problem

- Calls from Postman are fine

- The test feature within the Custom Connector returns 200 with data

- I can even wrap the API call into a Power Automate flow and respond in a Request/Response action to Power Apps and see the data.

 

It's just the final step of calling it directly within Power Apps that gives me the message above.   In Power Apps Monitor tool, the body return is blank when all the other test tools is showing a simple JSON array. I suspect this is the problem but I can't figure out how to use this observation.   I really don't want to hand roll all 11 operations into separate flows as a work around.  

 

I've also added flow.microsoft.com to the CORS policy of the API as described here  https://powerusers.microsoft.com/t5/Connector-Development/Property-quot-quot-type-mismatch-Expected-quot-object-quot/m-p/1283840#M461

 

I'm out of ideas - any suggestions would be gratefully received.

 

Many thanks

 

Jonathan

 

 

 

 

 

 

 

  • Verified answer
    basa314 Profile Picture
    40 on 21 Aug 2022 at 10:28:47
    Re: Power App + custom connector - The Data return in the response is invalid, Response data should be a valid JSON object

    With some help from Microsoft, we managed to solve this.  The problem turned out to be related to the API  being being deployed behind Azure API Management.

     

    The solution was to update the CORS policy for the API.  To do this, in the Azure Portal, select the API Management resource being used, APIs blade, All APIs, Inbound Processing, select the cors policy and add the following:

     

    <policies>
    <inbound>
    <cors allow-credentials="true">
    <allowed-origins>
    <origin>https://flow.microsoft.com</origin>
    <origin>https://pcmsapidev.developer.azure-api.net</origin>
    <origin>https://create.powerapps.com</origin>
    <origin>https://content.powerapps.com</origin>
    <origin>https://apps.powerapps.com</origin>
    <origin>https://make.powerapps.com</origin>
    <origin>https://authoring.eu-XXXXX.gateway.prod.island.powerapps.com</origin>
    </allowed-origins>

    etc.....

     

    It was the gateway.prod.island.powerapps.com line here that finally got this working after a few iterations with the support team.  I have not tried it with the lines above removed.

     

    You find the URL to use for your value of eu-XXXXX.gateway.prod.island.powerapps.com in the maker environment for your Power App under settings, Session Details, "Cluster URI suffix".

     

    If you find the above in any Microsoft documentation, your search skills are better than mine.

  • basa314 Profile Picture
    40 on 22 Jul 2022 at 11:11:25
    Re: Power App + custom connector - The Data return in the response is invalid, Response data should be a valid JSON object

    Thanks for the reply.   I've added that to the header and the problem is still there. See below from the header infor on the request copied from Monitor in Power Apps.

     

    "headers": {

        "Accept": "application/json",

        "x-ms-user-agent": "PowerApps/3.22072.25 (Web AuthoringTool; AppName=XXXX)",

        "x-ms-client-session-id": "XXXXX",

        "x-ms-client-request-id": " XXXXX ",

        "x-ms-client-environment-id": "/providers/Microsoft.PowerApps/environments/XXXX",

        "x-ms-client-app-id": "/providers/Microsoft.PowerApps/apps/XXXX",

        "x-ms-client-tenant-id": "XXXX",

        "x-ms-client-object-id": "XXXX",

        "Accept-Language": "en-GB",

        "Cache-Control": "no-cache, no-store",

        "x-ms-request-method": "GET",

        "x-ms-request-url": "/apim/XXXX"

      },

     

     

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on 22 Jul 2022 at 10:30:52
    Re: Power App + custom connector - The Data return in the response is invalid, Response data should be a valid JSON object

    @basa314 

     

    Check if adding

    {
     "Accept": "application/json"
    }


    in the Request header,

    helps with it to work from Power App formula and stop saying

    "The Data return in the response is invalid, Response data should be a valid JSON object".

     

    See if it helps @basa314 

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 42 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 41 Super User 2025 Season 1

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 36

Overall leaderboard