httpClient help

Post

Posted
Rating:
#1 (In Topic #1042)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
Hi Everyone

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

Code (gambas)

  1. hClient = New HttpClient As "hClient"
  2.  
  3.     With hClient
  4.         .URL = urlRequested
  5.         .Auth = 1
  6.         .User = Global.PS_USER
  7.         .Password = Global.PS_PASS
  8.         .Async = False
  9.         .Timeout = 60
  10.        
  11.         Select Case Methold
  12.             Case "GET"
  13.                 .Get
  14.        
  15.             Case "POST"
  16.                 .Post("application/connect.v2+json", jsonString)
  17.         End Select
  18.  
  19.     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

Code (gambas)

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

So this would be my new code

Code (gambas)

  1. hClient = New HttpClient As "hClient"
  2.  
  3.     With hClient
  4.         .URL = urlRequested
  5.         .Auth = 1
  6.         .User = Global.PS_USER
  7.         .Password = Global.PS_PASS
  8.         .Head(HeaddersArray.Data)
  9.         .Async = False
  10.         .Timeout = 60
  11.        
  12.         Select Case Methold
  13.             Case "GET"
  14.                 .Get
  15.        
  16.             Case "POST"
  17.                 .Post("application/connect.v2+json", jsonString)
  18.         End Select
  19.  
  20.     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.
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’

AndyGable said

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[]])
If you simply send the variable of type array:
   

Code (gambas)

  1. ......
  2.  .Head(HeaddersArray)
  3. ......
what happens ?

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

vuott said

AndyGable said

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[]])
If you simply send the variable of type array:
   

Code (gambas)

  1. ......
  2.  .Head(HeaddersArray)
  3. ......
what happens ?

i get the following error message

Can not load class string, Type Mismatch wanted integer got null
Online now: No Back to the top
1 guest and 0 members have just viewed this.