cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate I
Advocate I

Custom API : Incompatible Records

Hi, 

I´ve included a custom API to my PowerApp, this works fine - I think....

 

The Swagger look´s like this: 

{
    "swagger": "2.0",
    "info": {
        "version": "v1",
        "title": "Test Web Api"
    },
    "host": "test.webapi.com",
    "schemes": [
        "https"
    ],
    "paths": {
        "/api/Vu": {
            "get": {
                "tags": [
                    "Vu"
                ],
                "operationId": "GetVu",
                "consumes": [],
                "produces": [
                    "application/json",
                    "text/json"
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/VU"
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "Vu"
                ],
                "operationId": "Vu_Post",
                "consumes": [
                    "application/json",
                    "text/json",
                    "application/x-www-form-urlencoded"
                ],
                "produces": [
                    "application/json",
                    "text/json"
                ],
                "parameters": [
                    {
                        "name": "item",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/VU"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "object"
                        }
                    }
                }
            }
        },
        "/api/Vu/{id}": {
            "get": {
                "tags": [
                    "Vu"
                ],
                "operationId": "GetVuById",
                "consumes": [],
                "produces": [
                    "application/json",
                    "text/json"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "type": "integer",
                        "format": "int32"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/VU"
                        }
                    }
                }
            },
            "put": {
                "tags": [
                    "Vu"
                ],
                "operationId": "Vu_Put",
                "consumes": [
                    "application/json",
                    "text/json",
                    "application/x-www-form-urlencoded"
                ],
                "produces": [
                    "application/json",
                    "text/json"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "type": "integer",
                        "format": "int32"
                    },
                    {
                        "name": "item",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/VU"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "object"
                        }
                    }
                }
            },
            "delete": {
                "tags": [
                    "Vu"
                ],
                "operationId": "Vu_Delete",
                "consumes": [],
                "produces": [
                    "application/json",
                    "text/json"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "type": "integer",
                        "format": "int32"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "object"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "VU": {
            "type": "object",
            "properties": {
                "VUDescription": {
                    "type": "string"
                },
                "Location": {
                    "type": "string"
                },
                "Id": {
                    "format": "int32",
                    "type": "integer"
                },
                "Name": {
                    "type": "string"
                },
                "CreatedDate": {
                    "format": "date-time",
                    "type": "string"
                },
                "ModifiedDate": {
                    "format": "date-time",
                    "type": "string"
                },
                "CreatedBy": {
                    "type": "string"
                },
                "ModifiedBy": {
                    "type": "string"
                },
                "Version": {
                    "format": "byte",
                    "type": "string"
                }
            }
        }
    }
}

and the Get-Method from the API is returning following JSON:

[
  {
    "VUDescription": "TEst Item in DB",
    "Location": "Everywhere",
    "Id": 1,
    "Name": null,
    "CreatedDate": "2016-09-14T09:18:40.693",
    "ModifiedDate": null,
    "CreatedBy": "testuser@domain.com",
    "ModifiedBy": "testuser@domain.com",
    "Version": "AAAAAAAAB9M="
  }
]

Then I declared a ListBox in my PowerApp and set the Items Property of it to : MyApi.VuGet() but it then gets instantly red squiggles and says: The Property is awaiting Table-Values but got incompatible record values.

So, I just changed the Item Property of the Listbox to : Table(MyApi.VuGet()) but it the gets blue squiggles and says something like: Warning: The columns created by this rule are nested tables or datasets.... I know the API fetches some data because there is one blank item inside of the listbox , but I don´t know how to access any of the properties because the Auto-Completion feature isnt´t working also.

Do anyone of you have an advice? 

 

Thanks in advance,

Kamil

6 REPLIES 6
Community Support
Community Support

Hi Kamil-k,

 

Apologize that currently I don't have any custom API to test with.

Just from the error message, I could think of the following ways, which you may give it a try:

1. Under the item property of the listbox, add a dot at the end of MyApi.VuGet(), see if it would have any attributes listed, if yes, choose one which has no blank value;

2. Take use of Collect function to collect the data from your API, then use the Collection with the listbox.

Collect, clear and clearcollet functions in PowerApps

Hope the information above would be helpful.

Regards

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

Hi,

unfortunately it doesn´t help.

Community Champion
Community Champion

Hi @kamil-k, have you tried using the Ungroup function to open your nested records?

In any case what I would do is to ClearCollect(TempCollection, Table(MyApi.VuGet())) and then inspect the contents of TempCollectoin directly via the content tab of PowerApps Studio so you can see what structure the data has been returned with. You can see the column names as well as click through to any nested records/tables.

Please let me know if this helps.

 

 

PS Out of curiosity I tried the API and I seem to get the correct data structure into my TestCollection in PowerApps, please see screenshot below.

However I get a server error in PowerApps, so there is no data, and Swagger Editor also gives me an error.

 

VuCapture.JPG

Looks promising,  I will try it ASAP

Custom APIs do not presently have what PowerApps considers 'tabular' capabilities.  If you want this please up-vote here:

 

https://powerusers.microsoft.com/t5/PowerApps-Ideas/Custom-API-with-tabular-capabilities/idc-p/22385

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (7,891)