Folio ERM APIs

Folio ERM Agreement API

A draft Open API Specification (OAS) v3 is available at https://raw.githubusercontent.com/ostephens/folio-erm-agreements-api-os/main/dist.yaml

This file can be downloaded and used to generate API Collections in Postman (join the #learning-apis channel on the Folio Slack for more information). The OAS definition can also be pasted directly into the Swagger API editor to get an interactive version of the API

If using Postman, it is recommended to setup Postman environments with the following variables:

  • okapiPort (port number, if there is one, for Okapi)
  • okapiProtocol (http or https)
  • okapiUrl (url for the okapi server omitting protocol and port)
  • username (valid Folio user)
  • password (p/w for the Folio user)
  • x-okapi-tenant-value (to be used as the value for x-okapi-tenant for all requests)
  • x-okapi-token-value  (to be used as the value for x-okapi-token for all requests. Using the script below if the x-okapi-token is not set, it will be set automatically)
  • baseUrl (the url for Okapi, using the script below this will be built automatically from the okapiProtocol, okapiUrl and okapiPort)

For the Collection you have generated from the OAS definition, add the following as a Pre-request script. This will ensure that:

  • the baseUrl is built
  • the x-okapi-token-value is set. Note that you can set the baseUrl and x-okapi-token manually if you prefer by editing in the Environment variables directly
  • that the x-okapi-token-value and x-okapi-tenant-value are used to populate the x-okapi-token and x-okapi-tentant in all request headers
const xOkapiTenantValue = pm.environment.get("x-okapi-tenant-value");
const okapiPort = pm.environment.get("okapiPort");
const okapiProtocol = pm.environment.get("okapiProtocol");
const okapiUrl = pm.environment.get("okapiUrl");
const username = pm.environment.get("username");
const password = pm.environment.get("password");
const baseUrl = `${okapiProtocol}://${okapiUrl}${okapiPort?':'+okapiPort:''}`

pm.environment.set("baseUrl", baseUrl)
const loginRequest= {
url: `${baseUrl}/authn/login`,
method: 'POST',
header: [
"Content-type: application/json",
`x-okapi-tenant:${xOkapiTenantValue}`],
body: {
mode: 'raw',
raw: JSON.stringify({ "username": username,"password":password })
}
};

if (!pm.environment.get("x-okapi-token-value")) {
pm.sendRequest(loginRequest, function (err, res) {
pm.test('response should be okay to process', function () {
pm.expect(err).to.equal(null);
pm.expect(res).to.have.property('code', 200);
pm.expect(res).to.have.property('status', 'OK');
pm.response.to.have.header("x-okapi-token");
});
var token=res.headers.get("x-okapi-token")
pm.environment.set("x-okapi-token-value", token);
console.log(err?err:res.json());
console.log(res.json());
});
}


// example containing a test ** under the Tests tab only
pm.sendRequest('https://postman-echo.com/get', function (err, res) {
if (err) { console.log(err); }
});

//////
// Set okapi headers for authorisation to work
pm.request.headers.upsert({key: 'x-okapi-tenant', value: pm.environment.get('x-okapi-tenant-value') })
pm.request.headers.upsert({key: 'x-okapi-token', value: pm.environment.get('x-okapi-token-value') })


Folio ERM License RAML

RAML files for mod-licenses available at https://github.com/folio-org/mod-licenses/tree/master/ramls