DEV Community

Tech Community for Software AG Tech Community

Posted on • Originally published at tech.forums.softwareag.com on

Using the API Gateway Archive REST APIs to search for and download assets

products versions - API Gateway versions 10.x and up

Introduction

The webMethods API Gateway provides a number of REST APIs for managing assets and the gateway itself. Among those is the Archive API, which exposes two resources to export and import an archive:

GET /rest/apigateway/archive: Retrieves the archive, which is a ZIP file that contains the selected assets and its dependent assets.

POST /rest/apigateway/archive: Imports the API Gateway archive as well as exports the assets as an archive.

The POST resource is pretty straightforward. Likewise, the GET resource, by default, takes a query string of the assets you want to archive, along with their associated options. This is all well and good, if you know the names of all the assets you want to archive. Fortunately, there is a way to use the same criteria from the Search API to create and download an archive in a single step.

Executing the GET resource using POST and the x-HTTP-Method-Override header

The API Gateway uses the x-HTTP-Method-Override header to execute a resource other than the one matching the HTTP method of the request. This allows you to, for example, execute the GET resource of a REST API while sending a payload using the POST method.

x-http-override

The payload

As previously mentioned, the Archive API takes the exact same search criteria in the payload as the Search API. So, for instance, if you want to download all of the threat protection policies from the gateway, you could specify it in the payload this way:

{
    "types": [
        "policy"
    ],
    "scope": {
        "attributeName": "stageKey",
        "keyword": "threatProtection"
    }
}

Enter fullscreen mode Exit fullscreen mode

Similarly, to download all APIs the begin with “My” you could use this payload:

{
    "types": ["api"],
    "condition": "and",
    "scope": [{
        "attributeName": "apiName",
        "keyword": "My.*"
    }]
}

Enter fullscreen mode Exit fullscreen mode

As you can see, using search criteria can add a lot of flexibility to the Archive API.

Next steps

If you would like to learn more about using Gateway APIs, our YouTube channel has a short video tutorial. If you haven’t already, sign up for a fully functional free trial. See for yourself why Software AG has been named a Leader in the 2022 Gartner® Magic Quadrant™ for Full Life Cycle API Management for the fifth consecutive year.

Useful links | Relevant resources

To help you get started, here are the Archive Service and Sear Service Postman collections.

Archive API:

https://raw.githubusercontent.com/SoftwareAG/webmethods-api-gateway/master/apigatewayservices/postmancollections/apis/archive-service/ArchiveService.json

Search API:

https://raw.githubusercontent.com/SoftwareAG/webmethods-api-gateway/master/apigatewayservices/postmancollections/apis/search-service/SearchService.json

Read full topic

Top comments (0)