|
Hi,--
Why
rc = http_req('POST'
: APITokenURL
: ResponseFile
: *omit
: *omit
: FormData
: 'application/x-www-form-urlencoded');
and not
rc = http_req('POST'
: APITokenURL
: ResponseFile
: *omit
: *omit
: FormData
: Headers);
-----Message d'origine-----
De : RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> De la part de
(WalzCraft) Jerry Forss
Envoyé : mardi 14 octobre 2025 17:54
À : RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx> Objet :
Auth 2.0
ATTENTION : Ce message provient d'une source EXTERNE. Veuillez
n'ouvrir les liens ou pièces jointes que si vous êtes sûr de l'expéditeur.
Hi All
I am trying to build a new API to call TForce for shipping requests
that uses Auth 2.0.
I have done this in the past for FedEx and works but having issues
with TForce.
I can get the access token in Postman but is failing when I try from
my RPG pgm.
I am sure it's just something basic I am not understanding.
Postman request
Authorization
Auth Type 2.0
Body
client_id What we got for TForce
client_secret What we got for TForce
scope What we got for TForce
grant_type client_credentials
Works fine getting token
My RPG code
//
======================================================================
==============
// Prototype SetTokenHeader
//
======================================================================
==============
Dcl-Proc SetTokenHeader;
//
----------------------------------------------------------------------------------
// Input Parameters
//
----------------------------------------------------------------------
------------
Dcl-pi *N;
Headers VarChar(2000);
End-pi;
//
----------------------------------------------------------------------------------
// Local Parameters
//
----------------------------------------------------------------------
------------
//
----------------------------------------------------------------------------------
// Data Structures
//
----------------------------------------------------------------------
------------
//
----------------------------------------------------------------------------------
// Mainline
//
----------------------------------------------------------------------
------------
Headers = 'application/x-www-form-urlencoded' + CRLF;
End-Proc;
//
======================================================================
============== // Prototype CreateToken - Generate Token //
======================================================================
==============
Dcl-Proc CreateToken;
//
----------------------------------------------------------------------------------
// Input Parameters
//
----------------------------------------------------------------------
------------
// Dcl-pi *n;
// Token VarChar(100);
// End-pi;
//
----------------------------------------------------------------------------------
// Local Parameters
//
----------------------------------------------------------------------
------------
Dcl-S FormData Varchar(1000);
//
----------------------------------------------------------------------------------
// Data Structures
//
----------------------------------------------------------------------
------------
// Token Response From API Call
Dcl-ds TokenResponse Qualified;
access_token VarChar(2000);
token_type Char(20);
expires_in Packed(7 : 0);
scope Char(20);
End-ds;
//
----------------------------------------------------------------------------------
// Mainline
//
----------------------------------------------------------------------
------------
ResponseFile = %Trim(Path) + 'TForce_Token_Resp.json';
Rc = http_xproc(HTTP_POINT_ADDL_HEADER : %paddr(SetTokenHeader));
FormData = 'grant_type=client_credentials' +
'&client_id=' + %Trim(ClientID) +
'&client_secret=' + %Trim(APIKeyLive) +
'&scope=' + %Trim(APIScope);
rc = http_req('POST'
: APITokenURL
: ResponseFile
: *omit
: *omit
: FormData
: 'application/x-www-form-urlencoded');
Fails with RC of 400
Response json
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
https://urldefense.com/v3/__http://www.w3.org/TR/html4/strict.dtd__;!!
J76aczzK!xAjRZysEN8m9RA6wZidwhN2QTclHubpQuBYJVnQc3wqkUxK9ZGhxbLN8iWEQR
g0dQzKxgDXGtlOFJ69DFXxs4zi0$ "> <HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type"
Content="text/html; charset=us-ascii"></HEAD> <BODY><h2>Bad Request -
Invalid Header</h2> <hr><p>HTTP Error 400. The request has an invalid
header name.</p> </BODY></HTML>
Subject to Change Notice:
WalzCraft reserves the right to improve designs, and to change
specifications without notice.
Confidentiality Notice:
This message and any attachments may contain confidential and
privileged information that is protected by law. The information
contained herein is transmitted for the sole use of the intended recipient(s) and should "only"
pertain to "WalzCraft" company matters. If you are not the intended
recipient or designated agent of the recipient of such information,
you are hereby notified that any use, dissemination, copying or
retention of this email or the information contained herein is
strictly prohibited and may subject you to penalties under federal
and/or state law. If you received this email in error, please notify
the sender immediately and permanently delete this email. Thank You
WalzCraft PO Box 1748 La Crosse, WI, 54602-1748
https://urldefense.com/v3/__http://www.walzcraft.com__;!!J76aczzK!xAjR
ZysEN8m9RA6wZidwhN2QTclHubpQuBYJVnQc3wqkUxK9ZGhxbLN8iWEQRg0dQzKxgDXGtl
OFJ69DFfq5xCnQ$
<
https://urldefense.com/v3/__http://www.walzcraft.com__;!!J76aczzK!xAjR
ZysEN8m9RA6wZidwhN2QTclHubpQuBYJVnQc3wqkUxK9ZGhxbLN8iWEQRg0dQzKxgDXGtl
OFJ69DFfq5xCnQ$
Phone: 1-800-237-1326--
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://urldefense.com/v3/__https://lists.midrange.com/mailman/listinf
o/rpg400-l__;!!J76aczzK!xAjRZysEN8m9RA6wZidwhN2QTclHubpQuBYJVnQc3wqkUx
K9ZGhxbLN8iWEQRg0dQzKxgDXGtlOFJ69DFXgC-sSS$
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://urldefense.com/v3/__https://archive.midrange.com/rpg400-l__;!!
J76aczzK!xAjRZysEN8m9RA6wZidwhN2QTclHubpQuBYJVnQc3wqkUxK9ZGhxbLN8iWEQR
g0dQzKxgDXGtlOFJ69DFd1JxbRO$
.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.
--
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@xxxxxxxxxxxxxxxxxxxx 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.