cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
John_Martel
Frequent Visitor

Custom Connector Function failing with the Data Returned in the Response is Invalid

I have an Azure Function in my custom connector that returns "single" or "multi". I have built a Custom Connector (code below) and tested and it works fine (response below). As expected the body of the response has a single word. When I call the function from PowerApps i get "Data Returned in the Response in Invalid".

 

 

 

/SingleOrMulti:
    get:
      responses:
        '200':
          description: Success
          schema: {title: Similarity, type: string}
      summary: SingleOrMulti
      description: SingleOrMulti
      operationId: get-SingleOrMulti
      parameters:
      - {name: string1, in: query, type: string}

 

 

 

 
 

Response.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @John_Martel ,

Could you please share a bit more about the formula you executed within your canvas app?

Do you mean your Azure function could return a single value (Text String value)?

 

Based on the OpenAPI JSON definition that you mentioned, I could not find any syntax error with it. Please make sure your whole OpenAPI definition file looks like below:

{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "MyAzureFunction"
  },
  "host": "azurefn.azurewebsites.net",
  "paths": {
    "/api/HttpTriggerCSharp1": {
      "get": {
        "description": "Calls my azure function over https",
        "operationId": "RunThis",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "description": "code",
            "default": "h6ztu…[your code here]…i",
            "type": "string"
          },
          {
            "name": "name",
            "in": "query",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "schema": {
              "title": "The response of the api.",
              "type": "string"
            }
          }
        }
      }
    }
  }
}

More details about the creating a custom connector based on Azure function, please refer to the following blog:

https://powerapps.microsoft.com/de-de/blog/using-azure-functions-in-powerapps/

 

Please check if the result your Azure function returned is always a Text string value. As an alternative solution, you could consider re-define your Azure function, to make it return a Object value. Then based on the modified Azure function, re-generate a new custom connector, check if the issue is solved.

 

Within your canvas app, please execute your custom connector action within Behavior property of a control, e.g. OnSelect property of a button, rather than Non-Behavior property of a control.  Set the OnSelect property of a button to following:

Set(ReturnedValue, 'Custom Connector'.get-SingleOrMulti("xxxx"))

then check if the ReturnedValue variable is populated with proper value

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @John_Martel ,

Could you please share a bit more about the formula you executed within your canvas app?

Do you mean your Azure function could return a single value (Text String value)?

 

Based on the OpenAPI JSON definition that you mentioned, I could not find any syntax error with it. Please make sure your whole OpenAPI definition file looks like below:

{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "MyAzureFunction"
  },
  "host": "azurefn.azurewebsites.net",
  "paths": {
    "/api/HttpTriggerCSharp1": {
      "get": {
        "description": "Calls my azure function over https",
        "operationId": "RunThis",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "description": "code",
            "default": "h6ztu…[your code here]…i",
            "type": "string"
          },
          {
            "name": "name",
            "in": "query",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "schema": {
              "title": "The response of the api.",
              "type": "string"
            }
          }
        }
      }
    }
  }
}

More details about the creating a custom connector based on Azure function, please refer to the following blog:

https://powerapps.microsoft.com/de-de/blog/using-azure-functions-in-powerapps/

 

Please check if the result your Azure function returned is always a Text string value. As an alternative solution, you could consider re-define your Azure function, to make it return a Object value. Then based on the modified Azure function, re-generate a new custom connector, check if the issue is solved.

 

Within your canvas app, please execute your custom connector action within Behavior property of a control, e.g. OnSelect property of a button, rather than Non-Behavior property of a control.  Set the OnSelect property of a button to following:

Set(ReturnedValue, 'Custom Connector'.get-SingleOrMulti("xxxx"))

then check if the ReturnedValue variable is populated with proper value

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thanks I was bale to get working by converting the response to a JSon string, and then changing the Swagger format to Object.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (82,522)