REST API examples

API client batch scripts

You can use the client URL (curl) to run API commands. For more information about curl, please visit https://curl.haxx.se/.

Before executing a script, you need to encrypt the login password in a hidden file. You can then use this password in a script that obtains the login cookie.

Encrypt a password in a hidden file

To encrypt the password, run the command:

echo '<password to be encrypted>' | openssl enc -aes-256-cbc -md sha512 -a -salt -pass pass:'<password for the encrypted file>' > .pass.txt

To check that the encryption was successful, run:

cat .pass.txt | openssl enc -aes-256-cbc -md sha512 -a -d -salt -pass pass:'<password for the encrypted file>'

For example:

>echo 'MyPassword' | openssl enc -aes-256-cbc -md sha512 -a -salt -pass pass:’Admin112' > .pass.txt

>cat .pass.txt | openssl enc -aes-256-cbc -md sha512 -a -d -salt -pass pass:’Admin112'

MyPassword

The file .pass.txt is not visible if you perform an ls. To secure the .pass.txt file, use chmod to change the permissions on this file so others cannot access it.

chmod 600 .pass.txt

Use the following script to create an .sh file:

#!/bin/bash

HOSTNAME="<Central Governance hostname>"
PORT="<Central Governance port>"

DECODE () {
cat .pass.txt | openssl enc -aes-256-cbc -md sha512 -a -d -salt -pass pass:'<password for the encrypted file>'
}
LOW_PRIV_USERNAME="<Central Governance user>:<Central Governance Organization>"
LOW_PRIV_PASSWORD="$(DECODE)"

COOKIE_STORE=<file name where you want Central Governance cookies to be saved, including full file path>

LOGIN_REQ_BODY="<PassPortRequest id='2' sendAt='<current date>'><ssoLoginRequest><domain>CG</domain><username>"'<![CDATA['${LOW_PRIV_USERNAME}']]>'"</username><password>"'<![CDATA['${LOW_PRIV_PASSWORD}']]>'"</password></ssoLoginRequest></PassPortRequest>"

#echo ${LOGIN_REQ_BODY}

curl -c ${COOKIE_STORE} -k -X POST "https://${HOSTNAME}:${PORT}/Axway/authentication/" -H "Connection: keepalive" -H "Host: ${HOSTNAME}" -H "Content-Length: ${#LOGIN_REQ_BODY}" -d "${LOGIN_REQ_BODY}"

The current date should have the format YYYY-MM-DDThh:mm:ssTZD. For example, 2021-10-19T16:34:14-00:00.

For example, execute a GET on a list of Products:

curl -X GET -b <file path and name where you want Central Governance cookies to be saved> -k -v https://<CG hostname>:<CG port>/Axway/CentralGovernance/default/CentralGovernance/api/v2/products

Use the Try it out feature

The Try it out feature helps you to execute API commands from within the Swagger documentation. To use, select a command from within a resource, select the options, such as _brief=true, and then scroll to the bottom of the command. You can click the Try it out button to execute the command.

Common operations

Use the A2A and A2B examples provided in the next sections as a basis to test the various operations. From the listed resource, copy the text from the examples and execute. You can check the results in the Response Body, Response Code, and Response Headers.

Operations using either REST APIs or the user interface

You can perform the following tasks using either Central Governance REST APIs or the Central Governance user interface.

  • Create A2A flows
  • Create A2B flows
  • Manage SecureTransport backups
  • Retrieve Transfer CFT protocols

Operations available exclusively using REST APIs

You can perform the following tasks only via Central Governance REST API; you cannot perform these in the Central Governance user interface.

 

Central Governance | Document Directory

Related Links