Calling protected decision services
Before calling a protected decision service, you must have a user name and a password that can be used for the basic authentication header, and the right role that is authorized to call the corresponding decision services.
Using Java
The following Java™ code uses Apache HttpClient to set a basic authentication
header:
HttpRequest request = new HttpPost("…");
String baHeader = username + ":" + password;
String base64 = Base64 .getEncoder().encodeToString(baHeader.getBytes());
request.setHeader("Authorization", "Basic " + base64);Using cURL
Use
https://www.blitter.se/utils/basic-authentication-header-generator/ to
generate a basic authentication header. Then, use a cURL command to make an invocation. See the
following
example:#!/bin/bash URL= https://myservice.ibmcloud.com/odm/dev BASIC= dG90bzp0aXRp echo Invoking: $URL/res/api/ruleapps?count=true echo Response: curl -k -v $URL/res/api/ruleapps?count=true \ -H "Authorization: Basic $BASIC" echo