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

Error while registering custom API

Hello,

 

Help please.

 

I was just walking thourgh using the custom API in PowerApps. When I try to connect to an API endpoint using the trial swagger file that I've saved from here (http://petstore.swagger.io/v2/swagger.json) PowerApps fail with following error:

An error occurred while converting swagger file to WADL file. Error: 'Operation id "addPet" must specify either a default response or a 200-series response. Any other responses in the swagger is not supported by PowerApps client at JSON path paths./pet.post'. Your API may not work with apps.

 

Why is it so, although the swagger file I am uploading is one of the swagger.io provided? Otherwise, I would have guessed if swagger was not properly built.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

To unblock yourself, you can manually modify the swagger to add success responses to those operations that do not already have a 2xx response specified.

 

e.g., for the operation 'addPet', change the "responses" to:

"responses": {

"200": { "description": "Success." },

"405": { "description": "Invalid input" }

},

 

 

Also, there are a couple other things this swagger is using which is not currently supported by PowerApps. But these are only limitations of PowerApps, not invalid Swagger.

- Query parameters of type array are not supported. This affects operations: findPetsByTags and findPetsByStatus. To fix this, I just made the type of these parameters "string" and removed the extra properties.

View solution in original post

4 REPLIES 4
joem
Power Apps
Power Apps

Per the Swagger spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#responsesObject

The Responses Object MUST contain at least one response code, and it SHOULD be the response for a successful operation call.

 

But looks like their example isn’t actually to spec:

Here’s what that swagger operation looks like:

      "post": {

        "tags": [ "pet" ],

        "summary": "Add a new pet to the store",

        "description": "",

        "operationId": "addPet",

        "consumes": [ "application/json", "application/xml" ],

        "produces": [ "application/xml", "application/json" ],

        "parameters": [

          {

            "in": "body",

            "name": "body",

            "description": "Pet object that needs to be added to the store",

            "required": true,

            "schema": { "$ref": "#/definitions/Pet" }

          }

        ],

        "responses": { "405": { "description": "Invalid input" } },

        "security": [ { "petstore_auth": [ "write:pets", "read:pets" ] } ]

      },

 

405 is an error response. This operation doesn’t specify what a successful response is: e.g. any responses in the 2xx range.

 

So, unfortunately, it looks like their sample Swagger is invalid.

To unblock yourself, you can manually modify the swagger to add success responses to those operations that do not already have a 2xx response specified.

 

e.g., for the operation 'addPet', change the "responses" to:

"responses": {

"200": { "description": "Success." },

"405": { "description": "Invalid input" }

},

 

 

Also, there are a couple other things this swagger is using which is not currently supported by PowerApps. But these are only limitations of PowerApps, not invalid Swagger.

- Query parameters of type array are not supported. This affects operations: findPetsByTags and findPetsByStatus. To fix this, I just made the type of these parameters "string" and removed the extra properties.

KhadimAli
Frequent Visitor

Well, I've not really tried your proposed solution. Relying on you, I've marked it as answer.

JamesMi
Regular Visitor

I've just had a look at the PetStore swagger file with the latest version of PowerApps and it looks like Arrays are still not supported.

 

 

Any idea if this is on the roadmap?

 

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (5,639)