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 |
-- _______________________________________________ Ftpapi mailing list Ftpapi@xxxxxxxxxxxxxxxxxxxxxx http://scottklement.com/mailman/listinfo/ftpapi