[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] request data truncating when calling http_post



Have you tried searching the archives

 

http://www.scottklement.com/archives/ftpapi/

 

 

 

 

From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Daniel Stephens
Sent: Thursday, April 13, 2017 1:23 PM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: [Ftpapi] request data truncating when calling http_post

 

I have a very strange situation that I have finally narrowed down after much debugging. I don’t understand what’s happening and am hoping someone can shed some light. 

 

Basically I am creating some JSON (using Scott’s YAJL utility) that I then pass to HTTP_post. I use the YAJL_copyBuf to get the JSON into a variable we’ll call MYJSON. It’s defined in RPG as Varchar(32767:2). The actual data length is around 2020 characters but can be as much as 9000 in testing so far. 

 

I then pass the variable containing the JSON to HTTP_Post like this:

 

rc = http_post( 'myURL’'

                : %addr( myJSON : *data )

                 : %len( myJSON )

                 : '/ifs/path/to/result.json'

                 : HTTP_TIMEOUT

                 : HTTP_USERAGENT

                 : 'application/json' );

 

I’m getting a response back that indicates the JSON is invalid. When I look at the debug log (senddoc() entered ) it appears that the variable containing the JSON is losing the first 2 bytes (which are {“ - a left brace and double quote).

 

If I run the program with the Rdi debugger and hover over the myJSON variable it does indeed appear to be missing the first 2 bytes. If instead I create a monitor as “myJSON: c 2030” It appears to include the variable in its entirety. However, when I step into the http_post procedure and set a monitor on pePostData as “psPostData: c 2030”, the first 2 bytes are indeed missing.

 

I coded it this way based on an example Scott gave in answering another question. I ultimately was able to resolve this by simply removing the ‘*data’ from the second parameter. The problem is I don’t understand why that fixed it. Based on the Programmer’s Reference *DATA is supposed to point to the address of the actual data.

 

CFI

Dan Stephens

Systems Engineer Analyst Principal

 

4701 E. 32nd St.

Joplin, MO 64804 USA

P: 417-623-5229 ext. 5462

This e-mail and any files transmitted with it are confidential and solely for the use of the individual or entity to which they are addressed and intended. If you have received this e-mail in error, please notify the sender by return e-mail. If you are not the intended recipient, you may not read, copy, retain, print, disclose, or distribute this message or its contents to any other individual, for such actions may be unlawful. WARNING: We take certain precautions to prevent viruses, but we are not responsible for loss or damage arising from the use of this e-mail or attachments.

-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi