Skip to Content
Technical Articles
Author's profile photo Ajit Kumar Panda

SAP Commissions Rest API Basic Authentication from SAP Advanced Workflow

SAP Commissions Rest API allows 2 types of authentication i.e. Basic Authentication and JWT Token Authentication. Customer can choose any one type of authentication to make api calls from SAP Advanced workflow. This blog post will explain a sample of groovy script in SAP Advanced workflow to make api calls to SAP Commissions using basic authentication.

1) Create custom parameters in advanced workflow to Store commissions api endpoint url and credentials

Path: Set Up → DEVELOPMENT → Custom Parameters → Add New

Name Description Type Category Value
comm.api.uri  API End Point Text Commission https://<tenatid>.
comm.api.user User with Proper Authorization Text Commission <User Id>
comm.api.password Password Password Commission <Password>

2) Write a workflow Groovy script of ‘Util’ Type to make api calls to Commissions

Path: Set Up → DEVELOPMENT → Scripts → Add New


def fnPrepareCommHeaders(){
    def oHeaders = new java.util.HashMap();      
    oHeaders.put('Accept', 'application/json');
    def sUser = resp.getAppParam("comm.api.user");
    def sPassword = resp.getAppParam("comm.api.password");
    def sCredentials = sUser + ":" + sPassword ;
    def b64Credentials = sCredentials.bytes.encodeBase64().toString();
    def sAuthorizationHeader = "Basic " + b64Credentials;
    oHeaders.put('Authorization', sAuthorizationHeader);  
    return oHeaders;

def fnCallCommissionsAPI(sMethod, sUrl, sBody){
  	def oResponse;
  	def oHttpClient	= resp.createHttpClient();
  	def oHeaders	= fnPrepareCommHeaders();          
  	String sURL 	 = resp.getAppParam("comm.api.uri") + sUrl;  
      	case 'GET':
      		oResponse = oHttpClient.executeHttpGet(sURL, oHeaders);
      	case 'POST':
      		oResponse = oHttpClient.executeHttpPost(sURL, 'application/json', oHeaders, sBody);
      	case 'PUT':
      		oResponse = oHttpClient.executeHttpPut(sURL, 'application/json', oHeaders, sBody);
      	case 'DELETE':
      		oResponse = oHttpClient.executeHttpDelete(sURL, oHeaders);
    return oResponse;  	


3) Call above util function from any required script to Get/Create/Update/Delete any commissions resources.

Sample code to get Period Information from Commissions:

import groovy.json.JsonSlurper;
def utilCommApi = resp.importScript("commissions_functions");

def sResponse = utilCommApi.invoke("fnCallCommissionsAPI", 'GET', '/periods','')

def jsonSlurper = new JsonSlurper()
def jsonResponse = jsonSlurper.parseText(sResponse.getContent());"Periods-:", jsonResponse);


Conclusion – SAP Commissions can be integrated with Advacned workflow by calling Rest APIs using basic authentication.

You can also find additional information on following links:

Please feel free to provide any feedback you have in the comments section below and ask your questions about the topic in sap community using this link.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Yogananda Muthaiah
      Yogananda Muthaiah

      Another Great Article Ajit Kumar Panda ! On fire ..

      Author's profile photo Niranjan Ravulapalli
      Niranjan Ravulapalli

      Thanks Ajit for a very informative and detailed article