cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Groovy Rest API Call with Auth (Commissions API from Advanced Workflow)

nravulapalli1
Explorer
0 Likes
2,841

I have good bit of success with REST API calls using Python in the past but not able get a simple get request with basic auth working in Groovy. My final goal is to access Commission REST API from Advanced workflow.

Please share if you have a sample code snippet or point out what I am missing in my code snippet below (I ran variations the following script from my local machine with out much success)

Thanks in advance!

@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2')

import groovyx.net.http.RESTClient

RESTClient client = new RESTClient("https://XXXX.callidusondemand.com/api/v2/periods")

client.auth.basic "usename", "password"

// def path = "/api/v2/periods"

// def response

client.get(){ resp, data ->

println resp.status }

Accepted Solutions (0)

Answers (2)

Answers (2)

AaronQuandt
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Niranjan,

There is an example in the online documentation that should help: https://help.sap.com/viewer/b7cb13f8b6a04157a722ad9ddfde4a28/2110/en-US/72b1bf207c231014a804993ce404....

Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Niranjan,

I tried your scenario and here is some code to do so.

Configuration Params:

Util Code to make rest api calls: commissions-functions.txt

Calling Script : get-comm-period-data.txt

Regards, Ajit

nravulapalli1
Explorer
0 Likes

Thanks Ajit for your quick and detailed response. Should we setup com.api.user, com.api.uri and com.api.password in the "Custom Parameters" screen in workflow or these are in-built parameters? We are using Hana version of SAP Commissions.

Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert

Hi Niranjan,

Yes you have to maintain in custom parameters..

https://blogs.sap.com/2021/10/15/sap-commissions-rest-api-basic-authentication-from-sap-advanced-wor...

Best Regards, Ajit

nravulapalli1
Explorer
0 Likes

One more question, can we use groovyx.net.http.RESTClient from workflow?

Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert

sorry. I am not aware of that library. Try googling around that library and see how can it be used..