Hi All,
I am trying to figure out how to map what postman is doing to httpapi.
Postman code
curl --location --request POST '
https://api.ltl.xpo.com/token' \
--header 'Authorization: Basic &ourapikey&' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=&ourusername&' \
--data-urlencode 'password=&outpassword&'
Rpg code
RequestFile = %Trim(Path) + 'TokenRequest.json';
ResponseFile = %Trim(Path) + 'TokenResponse.json';
Rc = http_xproc(HTTP_POINT_ADDL_HEADER : %paddr(SetHTTPHeader));
// Build json Request
yajl_genOpen(*On);
yajl_beginObj();
yajl_addChar('grant_type' : 'password');
yajl_addChar('username' : %Trim(UserName));
yajl_addChar('password' : %Trim(Password));
yajl_endObj();
yajl_saveBuf(RequestFile : EMsg);
yajl_genClose();
http_setCCSIDs( 1208: 0 );
rc = http_post_stmf( TokenURL
: RequestFile
: ResponseFile
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'application/x-www-form-urlencoded');
From SetHTTPHeader
Headers = 'Authorization: Basic ' + %Trim(APIKey) + CRLF +
'Content-Type: ' + 'application/x-www-form-urlencoded' + CRLF;
This gives error 400 Bad Request
Changing 'application/x-www-form-urlencoded'); to 'application/json'); or commenting out that line
This gives error 415 Unsupported Media Type
What am I doing wrong?
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
www.walzcraft.com<
http://www.walzcraft.com> Phone: 1-800-237-1326
As an Amazon Associate we earn from qualifying purchases.