|
You just need to use the http_xproc() procedure to set up additional
headers
http_xproc( HTTP_POINT_ADDL_HEADER : %paddr(SetAuthorization));
Where SetAuthorization() is a procedure in your code that does the
following:
dcl-proc SetAuthoriation;
dcl-pi *n;
headers varchar(1024);
end-pi;
dcl-c CRLF const(x'0d25');
headers = 'Authorization: Basic +
v0dIcexyabhyMEdIOTdeSnBVWVNddvFSNevKODl6vVk6czvvYdJvd+
vgmZ2hpamtsbd5vcC8zrDJhYdU1YTEyNT2xMmY4NzVhZmU2M+
zg5NDc4YdNhdjd5MdUdYggdYTJdNvddYzEdOWFkdTvwZTFkdvVldTv2'
+ CRLF;
return;
end-proc;
Plenty of other examples from Scott...
Charles
On Tue, Apr 16, 2019 at 3:57 PM tim <iseriesstuff@xxxxxxxxx> wrote:
after further research, looks like the http_setoption only supports
specific options. "authorization" is not one of them.
I will try to modify HTTPAPIR4 and add that as an option to see if that
fixes the issue.
On 4/16/2019 5:33 PM, Adam Dodson wrote:
The HTTP 401 response code would indicate they're refusing authorizationto
the requested resource based the credentials you've provided. You maywant
to take this issue up with usaepay.--
Perhaps, you could tell us all this Mr. Doe's Social Security Numbe? ;)
Regards,
Adam B. Dodson
IT Dept.
Software Developer, Systems Administrator
Powercon Corporation
On Tue, Apr 16, 2019 at 5:00 PM tim <iseriesstuff@xxxxxxxxx> wrote:
I am trying to use rest to access usaepay system
(https://help.usaepay.info/developer/rest-api/) (code below).
Im getting the following error "HTTP/1.1 401 Valid authentication
required". I generated the key using the PHP sample code on the site.
H DFTACTGRP(*NO) BNDDIR('HTTPAPI':'QC2LE')
D myJSON s 500a varying
D authorization s 500a varying
D rc s 10i 0
/copy LIBHTTP/QRPGLESRC,httpapi_h
*inlr = *on;
myjson = ' +
{"command": "cc:sale", +
"amount": "5.00", +
"amount_detail": +
{ +
"tax": "1.00", +
"tip": "0.50" +
}, +
"creditcard": +
{ +
"cardholder": "John doe", +
"number": "4000100011112224", +
"expiration": "0919", +
"cvc": "123", +
"avs_street": "1234 Main", +
"avs_zip": "12345" +
}, +
"invoice": "12356" +
} +
';
http_debug(*on: '/home/tim/result.txt');
http_setOption( 'content-type' : 'application/json' );
http_setOption( 'user-agent' : 'uelib v6.8');
authorization = 'Basic +
v0dIcexyabhyMEdIOTdeSnBVWVNddvFSNevKODl6vVk6czvvYdJvd+
vgmZ2hpamtsbd5vcC8zrDJhYdU1YTEyNT2xMmY4NzVhZmU2M+
zg5NDc4YdNhdjd5MdUdYggdYTJdNvddYzEdOWFkdTvwZTFkdvVldTv2';
http_setOption( 'Authorization' : authorization);
rc = http_post( 'https://sandbox.usaepay.com/api/v2/transactions'
: %addr( myJSON : *data )
: %len( myJSON )
: '/home/tim/result.json'
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'application/json' );
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.
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.