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

Re: call WebApi requiring API token authorisation


Fabien Bodard

Le dim. 1 févr. 2026, 17:14, Lee <t.lee.davidson@xxxxxxxxx> a écrit :

> 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)
>

Too fast response from mine

Nevertheless the use of peek can be sometime simplier when you dl webpage
for internal treatement

For big files the too way (target file OR read event is better)

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

References:
Re: call WebApi requiring API token authorisationKKing <kicking177@xxxxxxxxx>
Re: call WebApi requiring API token authorisationLee <t.lee.davidson@xxxxxxxxx>