Here’s a quick tip for troubleshooting API calls:
If you are calling an API and notice that data you are expecting isn’t being provided, verify that you are allocating enough space for the return values and telling it how much space you’ve allocated.
Many APIs require you to allocate space to hold the returned info – but if you don’t tell the API how much space you’ve provided, it will only return the information that fits in the space it knows about.
Case in point … a co-worker and I were trying to use the QDBRTVFD api … our code was allocating 32k (yeah, a lot more than needed) … but the data length we provided was only 400 bytes (size of the header data structure).
The information we were interested in was actually in one of the sub-structures … but the offset value for that sub-structure was zero.
A bit of digging turned up that the API was returning 400 bytes of data for the call (in the QDBFYRET field)… but there were 1400 bytes of data available (QDBFYAVL field).
The fix was quite simple … we told the API that we were providing 32k of space (same amount we were allocating) and it worked fine.