|
It's not junk.. it's an ASCII (1208, UTF) representation. You're viewing
it through your EBCDIC session which is why it looks like garbage.
Can you turn on debug with HTTPAPI and have it save the request to a stream
file? Then look at that stream file instead to see what the JSON data
looks like.
I also think Scott has mailing lists dedicated to his offerings as well
that you may want to check out.
Brad
www.bvstools.com
On Thu, May 12, 2016 at 10:16 AM, Shubhadeep Roy <shubhadeep.roy@xxxxxxxxx
wrote:
Hi,with
A couple of points I need to mention-
1. getLogonInfo and http_setauth are working fine. I can confirm this
the header info being passed. I compared it with another application Iused
- Postman, for getting an OAUTH2 Token.:
2. I tried replacing the JSON creation code exactly as in Scott Klement's
example but the result is the same. I am not sure if the CCSID is causing
an issue or not. When I display jsonData, it shows junk values as shown
below-
JSONDATA =
....5...10...15...20...25...30...35...40...45
1 '# ÅÊ/>ȬÈ`øÁ Ä%ÑÁ>ȬÄÊÁÀÁ>ÈÑ/%Ë '
Please help. Thank you.
Here is the code-
D authUrl S 1024A Inz
D authToken S 24A Inz
D data_t s 20A Varying
D template
D jsonBuf_t s 200000a varying
D template
D JSON_BUF_SIZE c %len(jsonBuf_t)
P getAuthToken B Export
D getAuthToken PI 24A
*
D fd S 10I 0 Inz(3)
D CRLF C X'0d25'
D rc S 10I 0 Inz
D msg S 500A Inz
D runFlag S N Static
D size S 10I 0 Inz
D jsonBuf S like(jsonBuf_t)
D grant_type S like(data_t)
D dsLogonDetails DS Static
D dsAuthUsr 24A
D dsAuthPwd 24A
D dsAuthUrl 1024A
* getLogonInfo Prototype
D getLogonInfo PR 1072A
*
* Parse Incoming Data from http_url_post_raw
D parseHeader PR 10I 0
D 10I 0 Value
D * Value
D 10I 0 Value
*
D createJSON PR 10i 0
D data like(data_t) const
D jsonData like(jsonBuf_t)
*
/Free
http_debug(*ON : '/tmp/ShubhDebugLog.txt');
Clear authUrl;
// If not run, set static variables
If Not runFlag;
runFlag = *On;
// Get logon info
dsLogonDetails = getLogonInfo();
EndIf;
// Set Authorization
http_setauth(HTTP_AUTH_BASIC : dsAuthUsr : dsAuthPwd);
http_setCCSIDs( 1208: 0 );
grant_type = 'client_credentials';
createJSON(grant_type : jsonBuf);
rc = http_url_post_raw(dsAuthUrl : %addr(jsonBuf : *data) : size :
1 : %paddr('PARSEHEADER'));
If rc <> 1;
msg = http_error;
Clear authToken;
EndIf;
Return authToken;
/End-Free
P getAuthToken E
P createJSON B Export
D PI 10i 0
D grant_type like(data_t) const
D jsonData like(jsonBuf_t)
*
D rc s 10i 0
D len s 10i 0
D x s 10i 0
*
/Free
yajl_genOpen(*ON);
yajl_beginObj();
yajl_addChar('grant_type': %trimr(grant_type));
yajl_endObj();
%len(jsonData) = JSON_BUF_SIZE;
rc = yajl_copyBuf( 1208 : %addr(jsonData : *data) : JSON_BUF_SIZE
len);-------------------------------------------------------------------------------------
%len(jsonData) = len;
yajl_genClose();
Return rc;
/end-free
P createJSON E
*Debug Log*
HTTPAPI Ver 1.17 released 2006-09-23
New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_setauth(): entered
New iconv() objects set, PostRem=1208. PostLoc=0. ProtRem=819. ProtLoc=0
http_persist_open(): entered
http_long_ParseURL(): entered
https_init(): entered
Dump of local-side certificate information:-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
Dump of server-side certificate information:-------------------------------------------------------------------------------------
Cert Validation Code = 6000shubhadeep.roy@xxxxxxxxx>
-----BEGIN CERTIFICATE-----
udCsbg==
-----END CERTIFICATE-----
Serial Number: 18:C9:45:F1:B9:82:23:D9
Common Name: *.api.manheim.com
Org: Domain Control Validated
Issuer CN: Go Daddy Secure Certificate Authority - G2
Issuer Country: US
Issuer State/Province: Arizona
Issuer Locality: Scottsdale
Issuer Org: GoDaddy.com, Inc.
Issuer Org Unit: http://certs.godaddy.com/repository/
Unknown Field: 3
Unknown Field: 20150723153240
Unknown Field: 15:32:40 23-07-2015
Unknown Field: 20170723153240
Unknown Field: 15:32:40 23-07-2017
Unknown Field: 1.2.840.113549.1.1.11
Protocol Used: TLS Version 1
http_persist_post(): entered
http_long_ParseURL(): entered
do_post(): entered
POST /oauth2/token
Host: integration1.api.manheim.com
User-Agent: http-api/1.17
Content-Type: text/xml
Expect: 100-continue
Content-Length: 0
Authorization: Basic c2h2bWFoNXB1dTZ5OGsydGFkNTZ3eWdlOjN3Q0NjZ3VyRzg=
recvresp(): entered
HTTP/1.1 400 BAD_REQUEST
Content-Length: 0
Connection: Close
SetError() #13: HTTP/1.1 400 BAD_REQUEST
recvdoc parms: identity 0
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
SetError() #13: HTTP/1.1 400 BAD_REQUEST
http_close(): entered
On Mon, May 9, 2016 at 12:12 PM, Shubhadeep Roy <
wrote:token
Hi,
I am trying to Post to a URL with a username and password to get a
alsoback using HTTPAPI and YAJL and am getting BAD_REQUEST error. I have
--tried using the following instead of using the yajl set of commands to
generate the JSON-
myJson = '{ "grant_type": "client_credentials" }';
When I debug and check the contents of myJSON, I get junk values-
MYJSON =
....5...10...15...20...25...30...35...40...45
1 ' ÅÊ/>ȬÈ`øÁ Ä%ÑÁ>ȬÄÊÁÀÁ>ÈÑ/%Ë '
Can someone please help?
Here's the code below-
P getAuthToken B Export
D getAuthToken PI 24A
*
D CRLF C X'0d25'
D rc S 10I 0 Inz
D msg S 80A Inz
D runFlag S N Static
D myJSON S 65535A Varying
D size S 10I 0 Inz
*
D dsLogonDetails DS Static
D dsAuthUsr 24A
D dsAuthPwd 24A
D dsAuthUrl 1024A
*
* getLogonInfo Prototype
D getLogonInfo PR 1072A
*
* Parse Incoming Data from http_url_post_raw
D parseHeader PR 10I 0
D 10I 0 Value
D * Value
D 10I 0 Value
*
/Free
http_debug(*ON : '/tmp/ShubhDebugLog.txt');
Clear authUrl;
// If not run, set static variables
If Not runFlag;
runFlag = *On;
// Get logon info
dsLogonDetails = getLogonInfo();
EndIf;
// Set Authorization
http_setauth(HTTP_AUTH_BASIC : dsAuthUsr : dsAuthPwd);
http_setCCSIDs( 1208: 0 );
yajl_genOpen(*ON);
yajl_beginObj();
yajl_addChar('grant_type': 'client_credentials');
yajl_endObj();
yajl_copyBuf( 1208 : %addr(myJson) : %size(myJson) : size);
yajl_genClose();
rc = http_url_post_raw(dsAuthUrl : %addr(myJSON : *data) : size :
1 : %paddr('PARSEHEADER'));
If rc <> 1;
msg = http_error;
EndIf;
Return authToken;
/End-Free
P getAuthToken E
Here's the error message: HTTP/1.1 400 BAD_REQUEST
--
Warm regards,
Shubh
All is well. Everything will be OK!!! - Shubh
--
Warm regards,
Shubh
All is well. Everything will be OK!!! - Shubh
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.