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

Re: call WebApi requiring API token authorisation


On 1/31/26 10:24 PM, KKing wrote:
Hi Olivier/Lee,

Thank you for your suggestions ...

I do have
     hClientGet.Get(aHeaderOption, strMyFile)
working, and the file referenced by strMyFile has the expected response content.
and hClientGet.Status is fine

But
     sBuffer = Read #hClientGet, Lof(hClientGet)
returns an empty string. And ideally I'd like the content returned inline not in a file.

Suggestions?

K

Fabien and Bruce, your suggestion to use Peek over-complicates this. Using Peek is unnecessary.

K, the reason "Read #hClientGet" returns an empty string is because you have specified a file to receive the response.

As stated on the page for HttpClient.Get, "If TargetFile is specified, data received from the server will be saved in the specified file, and will be *not available in the internal memory buffer*." [emphasis added]

Further, "If TargetFile is not specified, data received from the server is stored in memory, and you can access the data using *standard stream methods* ..." [emphasis added] Just use "Read" after not specifying a file to receive the response, ie.:
hClientGet.Get(aHeaderOption)


--
Lee

--- Gambas User List Netiquette [https://gambaswiki.org/wiki/doc/netiquette] ----
--- Gambas User List Archive [https://lists.gambas-basic.org/archive/user] ----


Follow-Ups:
Re: call WebApi requiring API token authorisationFabien Bodard <gambas.fr@xxxxxxxxx>
References:
Re: call WebApi requiring API token authorisationKKing <kicking177@xxxxxxxxx>