[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unsupported_grant_type
[cid:image001.gif@01D1D29E.B68350E0]
Hi,
Attempting to create a simple RPG program which will obtain a
access-token, however when doing the http_url_post I receive back an
error "unsupported_grant_type".
Program is using a combination of HTTPAPI and powerEXT.
Here's the code as it stands:
/copy pextcd2/qsrc,pxapihdr General
H-Spec's
* powerEXT Service Program
Connector
/copy pextcd2/qsrc,pxapicgicn Basic HTTP connecter & Productivity
Services
/copy pextcd2/qsrc,pxapijsncn YAJL JSON connector
* Support for HTTPAPI by Scott
Klement
/copy
qrpglesrc,httpapi_h
* Declare Internal
Variables
d dsp s
50A
d dspwait s
1A
d rc s 10I
0
d i s 10I
0
d url s 2048A Varying
d tmpFile s 256a
varying
/free
// Clear powerEXT Service Program & Responce Object
clearSrvPgm();
// construct a JSON message with powerEXT JSON support
setContent('*none');
jsonNode('*object');
jsonNode('*string':'grant_type=':'password');
jsonNode('*string':'username=':'PSI');
jsonNode('*string':'password=':'Rohit66');
jsonEndNode();
// Construct a temporary result file name for HTTPAPI
tmpFile = '/tmp/tst'+uniqueKey+'.json';
// Setup HTTPAPI Url and parms
HTTP_debug(*on);
HTTP_SetCCSIDs(1208:0);
HTTP_SetFileCCSID(1208);
url = 'https://202.47.1.145/adfAPI/token';
// Send HTTPAPI Request
rc = http_url_post( url
: bufAddr()
: bufSize()
: tmpfile
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'application/x-www-form-urlencoded');
// HTTPAPI Error Handling
if rc <> 1;
dsply %char(rc);
dsp = http_error;
dsply dsp;
*inlr = *on;
return;
endif;
// Display HTTPAPI result with qcmd method
qcmd('dspf (''' + tmpFile + ''')');
// Delete object with qcmd method
qcmd('del (''' + tmpFile + ''')');
*inlr = *on;
/end-free
Regards,
Tony Cesarios
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------