wso2 / product-apim

Welcome to the WSO2 API Manager source code! For info on working with the WSO2 API Manager repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
845 stars 785 forks source link

Error while updating API through Rest API #11210

Open JoaozinhoKz4 opened 3 years ago

JoaozinhoKz4 commented 3 years ago

Description:

While trying to update an API throught publisher API v2, got the error below: Request Payload: { "name": "PizzaShackAPI", "context": "/pizzashack", "version": "1.0.0", "additionalProperties" : [{"name":"detailedDescripasdtion","value":"asdasd","display":true},{"name":"asd","value":"asdf","display":true}] } Response: { "code": 500, "message": "Internal server error", "description": "Error while updating the API : cf7bd734-0650-4626-940c-cf2dfcb87890 - 900763:No resources found::API must have at least one resource defined", "moreInfo": "", "error": [] }

Then I've tried to GET my API info using the rest API, this time using the devportal API, but unfortunatelly, my operations(resources) appears as blank, even if there are resources that can be checked at the portal.

image

image

Steps to reproduce:

1- Try to update an existing API using Publisher rest API, without sending operations at the request body 2- Try to get your API info, there will be no operations

Affected Product Version:

APIM 4.0.0 Publisher API v2 DevPortal API v2

Environment details (with versions):

vikumkbv commented 2 years ago

Please note that this is the expected behavior, even from Publisher UI we can not keep a API without any resource (Operations). when creating an API from UI also by default we are getting the resources with * .

Please refer the following screenshot for the error message we are getting if we tried to remove all resource(operations) paths (check right side bottom)

image

So to solve this issue you can use one of default resource (operation) in the payload as follows

 "operations": [
      {
        "target": "*",
        "verb": "POST",
        "authType": "Application & Application User",
        "throttlingPolicy": "Unlimited"
      }
    ]