httpClient help

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 363
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

httpClient help

Post by AndyGable »

Hi Everyone

I am using the below code to connect to my Cloud Card Server

hClient = New HttpClient As "hClient"

    With hClient
        .URL = urlRequested
        .Auth = 1
        .User = Global.PS_USER
        .Password = Global.PS_PASS
        .Async = False
        .Timeout = 60
        
        Select Case Methold
            Case "GET"
                .Get
        
            Case "POST"
                .Post("application/connect.v2+json", jsonString)
        End Select

    End With


I need to send over 2 addtion headers so I read online that I need to send them over as a string array so I set that up and added them as

Public HeaddersArray As New String[]  '(I assume this is how I set up a String array)
HeaddersArray.Add("Software-House-ID: SD45T92", 0)
HeaddersArray.Add("Installer-Id: " & Global.InstallerID, 1)


So this would be my new code
hClient = New HttpClient As "hClient"

    With hClient
        .URL = urlRequested
        .Auth = 1
        .User = Global.PS_USER
        .Password = Global.PS_PASS
        .Head(HeaddersArray.Data)
        .Async = False
        .Timeout = 60
        
        Select Case Methold
            Case "GET"
                .Get
        
            Case "POST"
                .Post("application/connect.v2+json", jsonString)
        End Select

    End With


but when I add them to the .Head function I get a error saying

Wanted String but got pointer instead

when I type .Head( the box underneath comes up and says "Headers as string[]])

I am totally stuck now how to send over the additional headers have i miss understood how to send the headers?

Anyone who can advise Please feel free to say or even if you can show me where I have gone wrong.
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: httpClient help

Post by vuott »

AndyGable wrote: Tuesday 9th May 2023 11:35pmbut when I add them to the .Head function I get a error saying

Wanted String but got pointer instead

when I type .Head( the box underneath comes up and says "Headers as string[]])
If you simply send the variable of type array:
......
 .Head(HeaddersArray)
......

what happens ?
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
AndyGable
Posts: 363
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: httpClient help

Post by AndyGable »

vuott wrote: Wednesday 10th May 2023 6:43am
AndyGable wrote: Tuesday 9th May 2023 11:35pmbut when I add them to the .Head function I get a error saying

Wanted String but got pointer instead

when I type .Head( the box underneath comes up and says "Headers as string[]])
If you simply send the variable of type array:
......
 .Head(HeaddersArray)
......

what happens ?
i get the following error message

Can not load class string, Type Mismatch wanted integer got null
Post Reply