I am getting a strange result when using HTTP_req
0136.00   dcl-s RESULTS          varchar(1600000) ;                               
0436.00       rc         = http_req( 'POST'                                     
0437.00               :'https://wwwcie.ups.com/security/v1/oauth/token'         
0438.00               : *omit                                                   
0439.00               : resultS          // String to receive the results       
0440.00               : *omit                                                   
0441.00               : 'grant_type=client_credentials'                         
0442.00               : 'application/x-www-form-urlencoded');      
When i look at the string results and compare it to the data that came back into my log on the ifs. The results string is shorter than the string I see in the log file.  The field , results only is 1021 where the field in the log is 1481. The log shows I am successful in obtaining the token. 
r Browse : /home/mydebuglog.txt                                                                                                      
 Record :     115   of     132 by  18                      Column :    1   1481 by  31                                              
 Control :                                                                                                                          
                                                                                                                                    
....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3. 
Connection: keep-alive                                                                                                              
Server-Timing: cdn-cache; desc=MISS                                                                                                 
Server-Timing: edge; dur=6                                                                                                          
Server-Timing: origin; dur=301                                                                                                      
ak-grn-1: 0.05931ab8.1714408008.28d4634b                                                                                            
Strict-Transport-Security: max-age=31536000 ; includeSubDomains                                                                     
Server-Timing: ak_p; desc="1714408008841_3088749317_685007691_30717_7775_59_76_-";dur=1                                             
                                                                                                                                    
                                                                                                                                    
SetError() #13: HTTP/1.1 200 OK                                                                                                     
recvresp(): end with 200                                                                                                            
recvdoc parms: identity 1481                                                                                                        
header_load_cookies() entered                                                                                                       
recvdoc(): entered                                                                                                                  
SetError() #0:                                                                                                                      
recvdoc(): Receiving 1481 bytes.                                                                                                    
{"token_type":"Bearer","issued_at":"1714408009193","client_id":"TyC9QTHSNd8JG9m4Nwg6HfAFKgAg150zVPVfqvELbaQANyg0","access_token":"ey
http_close(): entered                                                                                                               
 ************End of Data********************                                                                                        
                                                                                                                                    
 F3=Exit   F10=Display Hex   F12=Cancel   F15=Services   F16=Repeat find   F19=Left   F20=Right                                     
                                                                                                                                                                                                                     
Any help wiil be greatly appreciated
thanks 
Bruce
			
			
									
						
										
						OUATH2
- 
				Scott Klement
 - Site Admin
 - Posts: 935
 - Joined: Sun Jul 04, 2021 5:12 am
 
Re: OUATH2
How did you come to the conclusion that you've only received 1021?
The ILE Debugger in the operating system will, by default, only show 1024 characters. I could see how you might confuse that for only receiving 1021 (with a slight miscount) characters. Could that be what you're seeing?
The only other thing I can think to check is the size of your variable.
			
			
									
						
										
						The ILE Debugger in the operating system will, by default, only show 1024 characters. I could see how you might confuse that for only receiving 1021 (with a slight miscount) characters. Could that be what you're seeing?
The only other thing I can think to check is the size of your variable.
Re: OUATH2
Thank you for your quick response. I have been programming for a long time but was unaware of the ILE debugger constraint of 1024 characters. 
661 'TQ0OTIxMDksImlhdCI6MTcxNDQ3NzcwOSwianRpIjoiNzJjNWNlZmMtNDdiM'
721 'S00MzFlLWExNmEtMTVkMzU1Nzc3OTNlIn0.DnnM8Wzw3N25VlZ8brVVsAhF4'
781 '3LqpkuU7u8dpPA8FRVi6O5e6Jd9-FQcqlPn_9lLh1yFToNMpPn4G4ASZ8F5t'
841 'nbJn8IOBG2teb9bUWLD4PEgklEZAYa7Gkm-o5ZSGmc7CUAAU8_mwjzik_iMn'
901 'm4vyjThqdSNJue2f8N_eQaDIodMbxAL5qF_Ak4ufKcWH36Lbkp36Qq9mADfM'
961 'y5FB8F9kUT7SL-9dCJUmLbqXzyOa_hFa6-w4JtdegUTB1rdjFUe7592vQeNz'
1021 'G0xd'
 
Up until this spot (1024) the token is correct. My result field size is large enough to hold the token value.
Thank you once again for your help
			
			
									
						
										
						661 'TQ0OTIxMDksImlhdCI6MTcxNDQ3NzcwOSwianRpIjoiNzJjNWNlZmMtNDdiM'
721 'S00MzFlLWExNmEtMTVkMzU1Nzc3OTNlIn0.DnnM8Wzw3N25VlZ8brVVsAhF4'
781 '3LqpkuU7u8dpPA8FRVi6O5e6Jd9-FQcqlPn_9lLh1yFToNMpPn4G4ASZ8F5t'
841 'nbJn8IOBG2teb9bUWLD4PEgklEZAYa7Gkm-o5ZSGmc7CUAAU8_mwjzik_iMn'
901 'm4vyjThqdSNJue2f8N_eQaDIodMbxAL5qF_Ak4ufKcWH36Lbkp36Qq9mADfM'
961 'y5FB8F9kUT7SL-9dCJUmLbqXzyOa_hFa6-w4JtdegUTB1rdjFUe7592vQeNz'
1021 'G0xd'
Up until this spot (1024) the token is correct. My result field size is large enough to hold the token value.
Thank you once again for your help
- 
				Scott Klement
 - Site Admin
 - Posts: 935
 - Joined: Sun Jul 04, 2021 5:12 am
 
Re: OUATH2
As far as I can tell there isn't a problem, here.
If you want to see the whole string in the green-screen debugger, you can type this at the debuggger's command line:
That will show 1483 bytes of the variable.  (Keep in mind that a VARCHAR variable starts with either 2 or 4 bytes for the length of the data)
			
			
									
						
										
						If you want to see the whole string in the green-screen debugger, you can type this at the debuggger's command line:
Code: Select all
eval MY-VARIABLE:C 1483
Re: OUATH2
My initial issue obtaining the token seems to have been resolved.  I modified example 16 to get tracking information from  UPS  using the token rather than license, userid/ and password.  I am now getting the following error:  It looks like the program may not be reading the post correctly. If anyone has some input I sure would appreciate it. 
Thanks
 
(GSKit) I/O: Broken pipe.
ssl_error(406): (GSKit) I/O: Broken pipe.
SetError() #55: CommSSL_BlockWrite: send: (GSKit) I/O: Broken pipe.
Below is part of my code:
http_xproc( HTTP_POINT_ADDL_HEADER: %paddr(AddHeader) );
                                                               
postData =
'<?xml version="1.0"?>'
'<TrackRequest xml:lang="en-US">'
'<Request>'
'<TransactionReference>'
'<CustomerContext>'
'TRACKING TEST'
'</CustomerContext>'
'<XpciVersion>1.0001</XpciVersion>'
'</TransactionReference>'
'<RequestAction>Track</RequestAction>'
'<RequestOption>activity</RequestOption>'
'</Request>'
'<TrackingNumber>' + TrackingNo + '</TrackingNumber>'
'</TrackRequest>' ;
                                                                       
EVAL ACT = 0 ;
rc = http_url_post_xml('https://onlinetools.ups.com/ups.app/xml/Track
: %addr(postData) + 2
: %len(postData)
: %paddr(StartOfElement)
: %paddr(EndOfElement)
: *NULL) ;
if (rc <> 1);
scmsg = http_error();
// FIXME: REPORT ERROR TO USER
*inlr = *on;
return;
endif;
dcl-proc AddHeader ;
dcl-pi *n;
headers varchar(32767);
end-pi;
                                                                
Headers = 'Authorization: Bearer' + ' ' +
a_token + CRLF +
'Content-Type : application/x-www-form-urlencoded' + CRLF;
END-PROC addHeader ;
P StartOfElement B
D StartOfElement PI
D UserData * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D attrs * dim(32767)
D const options(*varsize)
/free
                                                                    
if path = '/TrackResponse/Shipment/Package' and name='Activity';
act = act + 1;
endif;
                                                                    
/end-free
P E
P EndOfElement B
D EndOfElement PI
D UserData * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 65535A varying const
D attrs * dim(32767)
D const options(*varsize)
/free
                                                                  
select;
when path = '/TrackResponse/Shipment/Package/Activity';
                                                                  
select;
when name = 'Date';
activity.Date(act) = value;
when name = 'Time';
activity.Time(act) = value;
endsl;
                                                              
when path = '/TrackResponse/Shipment/Package/Activity' +
'/ActivityLocation';
                                                              
select;
when name = 'Description';
activity.Desc(act) = value;
when name = 'SignedForByName';
activity.SignedBy(act) = value;
endsl;
                                                              
when path = '/TrackResponse/Shipment/Package/Activity' +
'/ActivityLocation/Address';
                                                            
select;
when name = 'City';
activity.City(act) = value;
when name = 'StateProvinceCode';
activity.State(act) = value;
endsl;
                                                            
when path = '/TrackResponse/Shipment/Package/Activity' +
'/Status/StatusType';
                                                            
if name = 'Description';
activity.Status(act) = value;
endif;
                                                     
endsl;
                                                   
/end-free
P E
			
			
									
						
										
						Thanks
(GSKit) I/O: Broken pipe.
ssl_error(406): (GSKit) I/O: Broken pipe.
SetError() #55: CommSSL_BlockWrite: send: (GSKit) I/O: Broken pipe.
Below is part of my code:
http_xproc( HTTP_POINT_ADDL_HEADER: %paddr(AddHeader) );
postData =
'<?xml version="1.0"?>'
'<TrackRequest xml:lang="en-US">'
'<Request>'
'<TransactionReference>'
'<CustomerContext>'
'TRACKING TEST'
'</CustomerContext>'
'<XpciVersion>1.0001</XpciVersion>'
'</TransactionReference>'
'<RequestAction>Track</RequestAction>'
'<RequestOption>activity</RequestOption>'
'</Request>'
'<TrackingNumber>' + TrackingNo + '</TrackingNumber>'
'</TrackRequest>' ;
EVAL ACT = 0 ;
rc = http_url_post_xml('https://onlinetools.ups.com/ups.app/xml/Track
: %addr(postData) + 2
: %len(postData)
: %paddr(StartOfElement)
: %paddr(EndOfElement)
: *NULL) ;
if (rc <> 1);
scmsg = http_error();
// FIXME: REPORT ERROR TO USER
*inlr = *on;
return;
endif;
dcl-proc AddHeader ;
dcl-pi *n;
headers varchar(32767);
end-pi;
Headers = 'Authorization: Bearer' + ' ' +
a_token + CRLF +
'Content-Type : application/x-www-form-urlencoded' + CRLF;
END-PROC addHeader ;
P StartOfElement B
D StartOfElement PI
D UserData * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D attrs * dim(32767)
D const options(*varsize)
/free
if path = '/TrackResponse/Shipment/Package' and name='Activity';
act = act + 1;
endif;
/end-free
P E
P EndOfElement B
D EndOfElement PI
D UserData * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 65535A varying const
D attrs * dim(32767)
D const options(*varsize)
/free
select;
when path = '/TrackResponse/Shipment/Package/Activity';
select;
when name = 'Date';
activity.Date(act) = value;
when name = 'Time';
activity.Time(act) = value;
endsl;
when path = '/TrackResponse/Shipment/Package/Activity' +
'/ActivityLocation';
select;
when name = 'Description';
activity.Desc(act) = value;
when name = 'SignedForByName';
activity.SignedBy(act) = value;
endsl;
when path = '/TrackResponse/Shipment/Package/Activity' +
'/ActivityLocation/Address';
select;
when name = 'City';
activity.City(act) = value;
when name = 'StateProvinceCode';
activity.State(act) = value;
endsl;
when path = '/TrackResponse/Shipment/Package/Activity' +
'/Status/StatusType';
if name = 'Description';
activity.Status(act) = value;
endif;
endsl;
/end-free
P E
- 
				Scott Klement
 - Site Admin
 - Posts: 935
 - Joined: Sun Jul 04, 2021 5:12 am
 
Re: OUATH2
Broken pipe means its trying to send more data after the network has disconnected.
Most likely, this is a network error not a programming error. Why are you getting disconnected?
			
			
									
						
										
						Most likely, this is a network error not a programming error. Why are you getting disconnected?
Re: OUATH2
I did rerun my request this morning and received a different message. 
                                                                                                                                    
senddoc(): entered
<?xml version="1.0"?><TrackRequest xml:lang="en-US"><Request><TransactionReference><CustomerContext>TRACKING TEST</CustomerContext><
<XpciVersion>1.0001</XpciVersion></TransactionReference><RequestAction>Track</RequestAction><RequestOption>activity</RequestOption><
</Request><TrackingNumber>1Z9627AW0310393753</TrackingNumber></TrackRequest>
recvresp(): entered
HTTP/1.1 400 Bad Request
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 282
Expires: Fri, 10 May 2024 12:12:11 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Fri, 10 May 2024 12:12:11 GMT
Connection: close
ak-grn-1: 0.8697c017.1715343131.2358d902
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
                                                                                                                
                                                                                                                
SetError() #13: HTTP/1.1 400 Bad Request
recvresp(): end with 400
recvdoc parms: identity 282
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
recvdoc(): Receiving 282 bytes.
<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>
An error occurred while processing your request.<p>
Reference #166.8697c017.1715343131.2358d902
<P>https://errors.edgesuite.net/166.8697c017.1715343131.2358d902</P>
</BODY></HTML>
			
			
									
						
										
						senddoc(): entered
<?xml version="1.0"?><TrackRequest xml:lang="en-US"><Request><TransactionReference><CustomerContext>TRACKING TEST</CustomerContext><
<XpciVersion>1.0001</XpciVersion></TransactionReference><RequestAction>Track</RequestAction><RequestOption>activity</RequestOption><
</Request><TrackingNumber>1Z9627AW0310393753</TrackingNumber></TrackRequest>
recvresp(): entered
HTTP/1.1 400 Bad Request
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 282
Expires: Fri, 10 May 2024 12:12:11 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Fri, 10 May 2024 12:12:11 GMT
Connection: close
ak-grn-1: 0.8697c017.1715343131.2358d902
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
SetError() #13: HTTP/1.1 400 Bad Request
recvresp(): end with 400
recvdoc parms: identity 282
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
recvdoc(): Receiving 282 bytes.
<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>
An error occurred while processing your request.<p>
Reference #166.8697c017.1715343131.2358d902
<P>https://errors.edgesuite.net/166.8697c017.1715343131.2358d902</P>
</BODY></HTML>
- 
				Scott Klement
 - Site Admin
 - Posts: 935
 - Joined: Sun Jul 04, 2021 5:12 am
 
Re: OUATH2
You are receiving the error "bad request", which indicates something is wrong with what you're sending.
From what you posted here, your document isn't valid XML. There are stray < characters at the end of some of the lines.
Keep in mind, though, that I can only really help you with HTTPAPI. I can't help you with specific APIs... I'd have to research them and learn them to help. I can offer you consulting services if you'd like that sort of help, but assuming your plan is to do it yourself, you'll need to learn what the API requires and troubleshoot problems.
			
			
									
						
										
						From what you posted here, your document isn't valid XML. There are stray < characters at the end of some of the lines.
Keep in mind, though, that I can only really help you with HTTPAPI. I can't help you with specific APIs... I'd have to research them and learn them to help. I can offer you consulting services if you'd like that sort of help, but assuming your plan is to do it yourself, you'll need to learn what the API requires and troubleshoot problems.
Re: OUATH2
is there a way to change the HTTP_TIMEOUT from the default?  I am trying to go through debug but the connections times out before I can see what is wrong with my post. I tried this but, I don't think it worked as it timed out. 
http_setOption('timeout': '600');
POST /api/ups.app/xml/Track HTTP/1.1██Host: onlinetools.ups.
com██User-Agent: http-api/1.45██Content-Type: text/xml██Cont
ent-Length: 305██
			
			
									
						
										
						http_setOption('timeout': '600');
POST /api/ups.app/xml/Track HTTP/1.1██Host: onlinetools.ups.
com██User-Agent: http-api/1.45██Content-Type: text/xml██Cont
ent-Length: 305██