Unable to add API to Application using Portal API
search cancel

Unable to add API to Application using Portal API

book

Article ID: 275980

calendar_today

Updated On:

Products

CA API Developer Portal

Issue/Introduction

When creating a new application using the Portal API, there's an issue when adding APIs to the application. These are the followed steps:


1. Create an app by making POST call to /api-management/1.0/applications - App created but status is Incomplete

2. Add API keys to the app by making a POST call to /api-management/1.0/applications/{AppUuid}/api-keys - Key is added to app

3. When adding the APIs to the Application by making a PUT call to api-management/1.0/applications/{AppUuid}/apis, there is a 400 response

Response:
{
 "error": {
 "code": "ValidationException",
 "message": {
 "lang": "en",
 "value": "The request could not be completed due to data input errors."
 },
 "detail": {
 "errorCode": "483",
 "devErrorMessage": "The request could not be completed due to data input errors.",
 "userErrorMessage": "The request could not be completed due to data input errors.",
 "userErrorKey": "error.validation.entity",
 "validationErrors": [
 {
 "field": "apiIds",
 "error": "The API Plan feature is on, an Application cannot associate with an API without an API PLAN.",
 "key": "error.validation.app.add.apiwithoutapiplan"
 }
 ]
 }
 }
}

There is an API plan associated with the organization and the API that is to be added to the application.  What is the process for adding an API to an application?

Environment

API Portal 5.2.1

Resolution

1. Instead of a PUT call to /api-management/1.0/applications/{AppUuid}/apis, do a PATCH call to /api-management/0.1/applications/{appUuid}/api-plans

2. Then do a PUT call to /api-management/0.1/applications/{appUuid}/api-plans

Please note that the endpoints are using 0.1 and not 1.0.