I am trying to be able to call the API for DocuSign and ROOMS for real state from our IBM i using RPGLE. I have not been successful. If someone has been able to accomplish this, can you share?
-
do you have any documentation on DocuSign? the SQL function HTTPPOSTCLOB can be used to call a web service from RPG. – RockBoro Apr 16 '21 at 14:04
-
Please take a look at the following: https://stackoverflow.com/help/how-to-ask. It would be helpful for you to post a specific example and the errors you are running into. – Player1st Apr 16 '21 at 16:06
3 Answers
Calling the DocuSign APIs requires that your server make HTTPS calls with the POST verb. Google gives some good results, see https://www.google.com/search?q=rpgle+call+rest+api
Also see this presentation by Scott Klement
Your best bet is to ask on RPGLE forums. Calling the DocuSign APIs and obtaining an OAuth access token (probably via the JWT grant) are the main issues. Once you're able to do that, the actual API requests can be sent either via JSON or XML.
A different idea might be to use a different server to communicate with DocuSign, if that would be easier. -- The second server could run Windows or Linux.

- 47,808
- 15
- 87
- 140
I run it in RDi debug and look at the values after the get to validate. This a sample of the GETACCNT2 RPGLE POC code to implement this: **FREE ctl-opt option (*srcstmt : *nodebugio : *nounref) actgrp(*caller); ctl-opt debug (*input);
dcl-pr getenv pointer extproc('getenv');
*n pointer value options(*string:*trim);
end-pr;
dcl-pr setEnv extpgm('SETENV');
end-pr;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Workfields
// - - - - - - -
dcl-s WebServiceUrl varchar(1024) inz;
dcl-s WebServiceHeader varchar(1024) inz;
dcl-s account varchar(200) inz;
dcl-s token varchar(1000) inz;
dcl-s qs_acname varchar(30) inz;
dcl-s acName varchar(30) inz;
//--------------------------------------------------------
account = '3d3e586b-XXXX-4d02-yyyy-f64a68cf41db';
setEnv();
// Get API key stored setENV
token = %str(getenv('ESIGN')) ;
Exsr SetUp;
Exsr ConsumeWs;
*Inlr = *On;
Return;
//--------------------------------------------------------
// SetUp subroutine
//--------------------------------------------------------
Begsr SetUp;
// this would be a soft-coded parameter passed to the program
WebServiceUrl =
'https://demo.docusign.net/restapi/v2.1/accounts/' + %trim(account) +
'?include_account_settings=true';
WebServiceHeader =
'<httpHeader>'+
'<header name="accept" value="application/json" />'+
'<header name="authorization" value= "Bearer '+ %trim(token)+ '"'+
'/>'+
'<header name="Accept-Encoding" value = "gzip,deflate,br"/>'+
'</httpHeader>';
Endsr;
//--------------------------------------------------------
// ConsumeWs subroutine
//--------------------------------------------------------
Begsr ConsumeWs;
Exec sql
Select ws_acname
INTO :qs_acname
from
Json_Table(Systools.HttpGetClob(:WebServiceUrl,
:WebServiceHeader),
'$'
Columns(ws_acname Varchar(30) Path 'lax $.accountName')
) As x;
acname = qs_acname;
Endsr;
SETENV CLLE code:
PGM /* Sets enviromnet variables with token values */
ADDENVVAR ENVVAR('ESIGN') +
VALUE('eyJ0eXAiO etc token key.... +
kiHX6jlcGbRKsyg8_5Klg9SS2S4upZ5AQ') REPLACE(*YES)
MONMSG MSGID(CPFA980)
ENDPGM
getenv is just a pointer to the Environment variable.

- 29
- 2
Was able to obtain a OAuth token and successfully did a Get Account using Systools.HttpGetClob late Friday Afternoon. Thanks for taking the time to respond to me.

- 29
- 2
-
1If you would post the working code, that would make this a good answer to the question. – Mike Apr 19 '21 at 15:34
-
1Yes, we'd love to see the code! Can you put it up on github somewhere? – Larry K Apr 19 '21 at 19:12