× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Can you turn on debugging and get a copy of the actual request that was
sent, including headers?

Also, for the response, the same?

Brad
www.bvstools.com

On Mon, May 9, 2016 at 11:12 AM, Shubhadeep Roy <shubhadeep.roy@xxxxxxxxx>
wrote:

Hi,

I am trying to Post to a URL with a username and password to get a token
back using HTTPAPI and YAJL and am getting BAD_REQUEST error. I have also
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
​​
--
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 thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.