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 Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,211)