Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 4NtngCTviFgmibndDSfZm4
Power Apps - Building Power Apps
Suggested answer

Checking for errors on an API call through a custom connector

Like (3) ShareShare
ReportReport
Posted on 26 Nov 2020 16:21:36 by 33

I have a custom connector which points to an API. Reading or writing to the API seems to work as expected but I would like to handle any errors that may occur.

Is this even possible?

I have searched the community and seen some references mentioning this type of functionality but they are from last year and do not explain how to gain access to the specific error returned by the API.

Can anyone help?

  • Suggested answer
    CU02041222-0 Profile Picture
    2 on 02 Apr 2025 at 12:25:42
    Checking for errors on an API call through a custom connector
    You don't need to use custom code in your connection to handle this.
     
    Let's say you have a custom connector that retrieves something from a custom API.
     
    After that custom connection add a "Response to Power App or flow" action. Configure two outputs as follows.
     
    "status" set to "outputs('ConnectorID')['statusCode']"
    "body" set to "body('ConnectorID')"
     
    Then on the Respond action, click the three dots and click "Configure run after", then ensure "is successful" and "has failed" are both ticked, you can also tick "has timed out" if required.
     
    Now even if your action returns an error code, whatever called you flow will get back the status code and message body and can implement whatever error handling is appropriate.
  • sankarssn Profile Picture
    2 on 03 Apr 2024 at 06:06:48
    Re: Checking for errors on an API call through a custom connector

    We can achieve this by using custom connector code to manipulate request and response (based on http status code). only drawback is backend API wait timeout will reduce from 2 minutes to 5 seconds, if your enabling code in custom connector

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on 29 Nov 2020 at 12:33:16
    Re: Checking for errors on an API call through a custom connector

    @Tricky 

     

    To my awareness, that is not possible, if you can control the API, the API must likely have to be modified to always return the 200 response and you probably need to abstract away the actual error code elsewhere in the API. Reason is because any other code such as an error status code is interpreted as if it were an internal error in the Custom Connector. Then the Custom Connector will actually retry the connection instead, not pass through and return an error message. I do not believe this can be changed.

     

    If you are trying to check for if there is an internal error (e.g. usually because the actual backend behind the Custom Connector is down), that is possible with an advanced way with IfError, but it requires experimental features to be enabled to do this, and you cannot get the Error message at all, this is just to check if any error was returned, so this way with the experimental one, it can be detected if the Custom Connector backend could never be contacted after the several attempts it would make.

     

    See Ref: Error, IfError, IsError, IsBlankOrError

     

    No exact error code can be obtained this way. It is just a trick to be able to find out if the Custom Connector could never contact the backend in the first place. If you try this it would have to be used with an advanced way with Timers. If your API returns any error status code, it will probably be misinterpreted as this kind of situation too - the API cannot return any error HTTP status codes to my awareness.

     

    Note that the above is the only thing I am aware you can do and it is not related directly to what you are asking. About what you are asking, The first part where the API must return 200 status code is only way I know of and no way around it.

     

     

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!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started