Using the API Gateway Archive REST APIs to search for and download assets
Tags: api, apigateway, restapi, webmethods
Published: 2023-03-01 12:00:44

---
title: Using the API Gateway Archive REST APIs to search for and download assets
published: true
date: 2023-02-04 02:29:56 UTC
tags: api, apigateway, restapi, webmethods
canonical_url: https://tech.forums.softwareag.com/t/using-the-api-gateway-archive-rest-apis-to-search-for-and-download-assets/268852
---

 

_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](https://global.discourse-cdn.com/techcommunity/optimized/3X/8/2/824c414b987ec2fc17aacb6d748130a6e9b95939_2_517x214.png)](https://global.discourse-cdn.com/techcommunity/original/3X/8/2/824c414b987ec2fc17aacb6d748130a6e9b95939.png "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"
    }
}

```

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

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

```

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](https://www.youtube.com/watch?v=MlyGo14TkOY&list=PL3HwmrSYjxiNPb9CkcmJYqSCYvue9IIZD&index=32). If you haven’t already, [sign up for a fully functional free trial](https://signup.softwareag.cloud/#/basic-b). 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](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](https://raw.githubusercontent.com/SoftwareAG/webmethods-api-gateway/master/apigatewayservices/postmancollections/apis/search-service/SearchService.json)

[Read full topic](https://tech.forums.softwareag.com/t/using-the-api-gateway-archive-rest-apis-to-search-for-and-download-assets/268852)