Whether it is webMethods, Kong, Apigee, Azure API Management or MuleSoft, every gateway and integration platform eventually poses the same question: how to move from mouse-driven administration to an automated, versioned and verifiable configuration? Promoting an API between environments, applying the same policies everywhere, replaying a configuration after an incident: everything goes through the platform’s administration API, and each has its peculiarities.
Our first field of proof was webMethods API Gateway 10.15 and its administration REST API (under /rest/apigateway). This article gathers the behaviours that cost us time on these automation chains. These behaviours are not obvious and break naïve scripts quietly. The lessons, however, hold well beyond webMethods.
Warning: the behaviours described were observed on 10.15 installations with a given patch level. Check them on your own version and your own fixes before making them a pipeline assumption. The reference fix level depends on each installation and must be confirmed in your environment.
1. Responses are wrapped, and the envelope changes with the object
An automation script’s first reflex: read an API, change a field, send it back. With API Gateway, the response to a GET is not the object itself but an envelope. For an API, one typically receives an apiResponse object that contains the API and a status; for a policy action, a policyAction object; for other resources, a different key again.
Practical consequences:
- a script that sends the result of a
GETas-is in aPUTsends the envelope, not the expected object; - depending on the endpoints, this error is not always translated into a clear rejection;
- a generic parser (“take the first object in the response”) sooner or later reads the wrong key.
What we do: a small access layer per resource type, with explicit, tested “unwrap” and “wrap” functions. Each type has its written contract, and a test compares the real response of a staging environment with that contract.
2. Policy bodies are nested more deeply than one thinks
A policy applied to an API is not a flat object. It references policy actions, which themselves carry parameters as lists of typed values. To change a single parameter (a header, a limit, a routing endpoint), one must go down several levels, then send the complete object back.
The pitfalls we have met:
- partial modification does not really exist: one must reread, modify and send the entire action back, otherwise parameters disappear;
- the order and type of values matter: a value expected as a list but sent as a string may be accepted and then ignored;
- identifiers change between environments: a policy action recreated in another environment does not have the same identifier, which rules out copying raw references.
What we do: we never version technical identifiers in Git. We version a readable description (“this API uses this authentication, this routing, this limit”) and the pipeline resolves the identifiers at deployment time, environment by environment.
3. Aliases are not stored as they are read
Aliases are the natural tool for a single API definition to point at different backends depending on the environment. In the REST API, some alias values do not appear in the form in which they were entered: depending on the alias type and the fields involved, one may find encoded values (in base64 in particular) or restructured ones.
The danger is twofold:
- a naïve comparison of the value read and the value expected produces a false “different”, hence useless redeployments;
- or, worse, a false “identical” when the script compares two representations encoded differently.
What we do: every alias comparison goes through an explicit normalisation (decoding, field sorting, removal of non-functional metadata) before the difference is computed. And sensitive alias values (secrets, passwords) never transit through Git: they are read at runtime from a secrets vault.
4. A 200 does not mean “it is done”
This is the most costly pitfall, because it is silent. Some calls respond with an HTTP 200 even though the operation did not have the expected effect: object unchanged, error status in the response body, or action ignored because the starting state did not allow it (for example an API in a state that does not permit the requested operation).
A pipeline that trusts the HTTP code shows green while production diverges from Git.
What we do: every write is followed by a reread and a check of the final state. “I have sent the configuration” is not enough; one must be able to write “I have reread the configuration and it matches”. Concretely:
- read the state beforehand;
- write;
- reread;
- compare the reread state with the expected state, after normalisation;
- fail loudly in case of a discrepancy.
It is slower, but it is the only way to have a pipeline that tells the truth.
5. The activation state conditions what one is allowed to do
An active API and an inactive API are not modified in the same way, and some operations require a precise state. A script that chains “deactivate, modify, reactivate” without checking each step can leave an API deactivated after an intermediate error, to the detriment of consumers.
What we do: we avoid as far as possible touching a version in service. The new version is deployed alongside, verified, then traffic is switched; the old one is withdrawn only afterwards. This is the overlap strategy, which we will detail in a forthcoming article on credential rotation.
6. Archive export and import: practical, but not neutral
Export/import archives are often the simplest path for promoting APIs between environments. They have their own subtleties:
- the exact content of an archive depends on what one asks to export (APIs alone, with or without dependencies such as applications, aliases or global policies);
- an import with overwrite can replace elements one did not intend to touch;
- an archive is a binary: without processing, it is a poor fit for code review.
What we do: the archive remains a transport format, never a source of truth. The source of truth is the readable description in Git; the archive is produced by the pipeline, inspected, then imported, with a post-import check identical to the one in point 4.
What holds for any gateway
The details change from one vendor to another: shape of responses, policy model, secret handling, version lifecycle. The pattern, however, comes back on every API or integration platform one automates: an administration API designed first for a console, not for a pipeline. The same reflexes therefore apply everywhere: never assume the shape of a response, normalise before comparing, and reread after every write.
What to take away
Automating an API gateway is entirely feasible, provided every response from the administration API is treated as data to be validated, not as a confirmation. Three rules cover the essentials, on webMethods as elsewhere:
- an explicit contract per resource type, with tested wrapping and unwrapping;
- normalisation before any comparison (aliases, policies, metadata);
- a systematic reread after every write, with a loud failure in case of a discrepancy.
On our chains, these rules translate into a suite of automated checks, replayable at every deployment, whose scope is adapted to the platform.
In the next article, we assemble these building blocks into a complete deployment chain with Jenkins, Ansible and GitLab.
Alongside its consulting work, CAB Ingénierie develops STOA, a sovereign iPaaS and API integration platform.
Let's talk about your project
Do your automation scripts show green while your environments diverge, or are you preparing a version upgrade or a gateway change? Tell us about your context in a few lines: cab-ingenierie.com · contact@cab-ingenierie.com