Include Additional Headers in the API Console¶
<API-M_HOME>/repository/conf/deployment.toml file, and specify the additional headers (
userId in this case) under the
[apim.cors] section. Alternatively, you could choose to add this additional header only to a specific API (for more information, see Enabling Cors per API).
CORS configurations in deployment.toml
[apim.cors] enable = true allow_origins = "*" allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"] allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction","userId"] allow_credentials = false
Next, let's see how to add the header as a parameter to the API Console.
- Log in to the API Publisher and click the API that you want to invoke (e.g.,
Click on the API and navigate to the resources tab. Choose the required resource (e.g
POSTmethod) to expand it. Note the parameters section highlighted below.
Add a header parameter with the name
userId. Once added the the newly added parameter should be listed as follows.
Once you are done, click Save .
Log in to the Developer Portal, subscribe to the API and generate an access token for the application you subscribed with. Once done Click on the API and then navigate to the API console via the Test button.
Once you expand the modified resource, you would notice that the added header parameter is visible in the API console and expecting an input.
You have now successfully added a header parameter to the API Console.Top