[Gambas-user] httpget issue

Antonio Teixeira antonio.j.teixeira at gmail.com
Thu Mar 2 15:42:55 CET 2023


Hi everyone,

I am trying to use the httpget class in gambas but I am having issues.
The curl that is working is :

curl --location --request POST 'https://192.168.10.110:50301/api/user/Login'
\
--header 'Content-Type: application/json' \
--data-raw '{
"username" : "a",
"password" : "a"
}'
the answer is
"code":0,"message":"No
error","data":{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Nzc3Njg3MjQuNjk2MTg0LCJpYXQiOjE2Nzc3Njc4MjQuNjk2MTY5LCJuYmYiOjE2Nzc3Njc4MjQuNjk2MTc5LCJyZW1vdGVBY2NvdW50IjpmYWxzZSwic3ViIjoiQ2FzaG1hdGljIEpXVCB0b2tlbiIsInVpZCI6MX0.498btABtMc40u57mLczvFasEL89llI9RlHC4dvlD_xA"}}

The code I am using in gambas is :

Private Sub DoLogin()
  Dim data As String
  Dim headers As New String[]
  Dim resposta As String

  hClient.URL = "https://192.168.10.110:50301/api/user/Login"
  hClient.Async = False
  hclient.Auth = Net.AuthNone
  hclient.SSL.VerifyHost = False
  hclient.SSL.VerifyPeer = False
  hClient.Timeout = 2
  headers.Add("Content-Type: application/json")
  data = "username=a&password=a"
  hClient.Post("application/json", data) ', headers)
  'hClient.get(headers)
  Resposta = hclient.Peek()
  Message(Resposta, "OK")
End Sub


I am getting always "Bad Request"

Any help please?

Thanks in advance.

Atentamente / Regards

António Teixeira
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230302/49137178/attachment.htm>


More information about the User mailing list