[Gambas-user] ​httpget issue

Antonio Teixeira antonio.j.teixeira at gmail.com
Fri Mar 3 17:34:00 CET 2023


Hi T Lee,

Thank you for your answer.
Replacing the data content from "username=a&password=a" to
"{'username'='a'&'password'='a'}"
did not solve the problem. The answer "Bad Request" remains.
Any other ideas?

Atentamente / Regards

António Teixeira


On Thu, 2 Mar 2023 at 19:05, <user-request at lists.gambas-basic.org> wrote:

> Send User mailing list submissions to
>         user at lists.gambas-basic.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.gambas-basic.org/listinfo/user
> or, via email, send a message with subject or body 'help' to
>         user-request at lists.gambas-basic.org
>
> You can reach the person managing the list at
>         user-owner at lists.gambas-basic.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of User digest..."
>
>
> Today's Topics:
>
>    1. Re: httpget issue (T Lee Davidson)
>    2. Re: Problem with Embedded Server (T Lee Davidson)
>    3. Re: Event WebTable.Click (Bruce Steers)
>    4. Re: Event WebTable.Click (Bruce Steers)
>    5. Re: Event WebTable.Click (Bruce Steers)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 2 Mar 2023 11:16:43 -0500
> From: T Lee Davidson <t.lee.davidson at gmail.com>
> To: user at lists.gambas-basic.org
> Subject: Re: [Gambas-user] httpget issue
> Message-ID: <64c993aa-675d-132d-c8a2-8d87a4659db5 at gmail.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> On 3/2/23 09:42, Antonio Teixeira wrote:
> > Hi everyone,
> >
> > I am trying to use the httpget class in gambas but I am having issues.
> > The curl that is working is :
> >
> [snip]
> >
> > 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 <
> 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
>
> First off so that others don't get confused, there is no httpget class. I
> think you probably meant HttpClient.
>
> It appears the data you are sending is not in JSON format:
> data = "username=a&password=a"
>
> try:
> data = "{'username'='a'&'password'='a'}"
>
> Tip: The gb.util.web component has a JSON class that has encode and decode
> methods:
> https://gambaswiki.org/wiki/comp/gb.util.web/json
> (You may already know this, but others may not.)
>
>
> --
> Lee
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 2 Mar 2023 11:21:02 -0500
> From: T Lee Davidson <t.lee.davidson at gmail.com>
> To: user at lists.gambas-basic.org
> Subject: Re: [Gambas-user] Problem with Embedded Server
> Message-ID: <c87ee92a-9ba1-96cc-e8ce-1b00a8ee3f80 at gmail.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> On 3/2/23 06:20, Claus Dietrich wrote:
> [snip]
> >
> > On 3/1/23 14:46, T Lee Davidson wrote:
> >> I got webapp4_Prelease-3.7.7.tar.gz from the link Clause posted. But,
> then Hans sent me an updated version,
> >> webapp4-3.7.12.tar.gz.
> >
> >> With v3.7.12 I cannot reproduce the issue. I have launched and
> relaunched it a number of times immediately after another;
> >> running through all the top menu items each time. It works fine here.
> :-\
> >
> > As described it doesn't occur when launching the app. The stall happens
> when changing the selection of the menu tabs.
>
> And, that is exactly what I did many times: "running through all the top
> menu items each time." I could not make it fail.
> [snip]
>
> --
> Lee
>
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 2 Mar 2023 16:48:53 +0000
> From: Bruce Steers <bsteers4 at gmail.com>
> To: Gambas Mailing List <user at lists.gambas-basic.org>
> Subject: Re: [Gambas-user] Event WebTable.Click
> Message-ID:
>         <
> CABuQYCAx9chUmgQsZ5ZOPS4jbBHWkWk5Y8bXKx7qrhG3hmoU1A at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> On Thu, 2 Mar 2023 at 16:08, Mayost Sharon <sharon at 455.co.il> wrote:
>
> > Hello
> >
> > I know it's just for show
> > but
> > While I fill the cell with the button
> > data.control=WebButton
> > So when I click on the button that is in a certain cell I get an event
> of:
> > WebTable1_Click(Row As Integer, Column As Integer)
> > Then I can know from which row and which column the button is pressed
> > And it provides me with information on how to access a database to
> > retrieve the information I need
>
>
> showing the button text in the example code we have been using the text
> showed
> Button:1_1 for row 1 column 1
> Button:2_1 for row 2 column 1
>
> (there is row/col identity there)
>
> You can also use the button.Name to give a unique name stating Row/column
> while having same button text on all buttons.
>
> Also button.Tag
>
> So of course you can tell what button was clicked from what row./col,
> by smart naming as your code has done all along..
>
> Public Sub WebTable1_Data(Row As Integer, Column As Integer, Data As
> WebTableData)
>
>  Select Case Column
>     Case 0
>       Data.Background = Color.SetAlpha(Color.Yellow, 192)
>       Data.Text = "Data: " & CString(Row) & "_" & CString(Column)
>     Case 1
>       Dim wb As WebButton = New WebButton(Me) As "BUT"
>       wb.Text = "DangerButton"
>      wb.Name = "btnDanger_" & CString(Row) & "_" & CString(Column)
>       wb.Class = "button is-danger"
>       Data.Control = wb
>   End Select
>
> End
>
> Public Sub BUT_Click()
>
>   Dim iRow, iCol as Integer
>   iRow = Split(Last.Text, "_")[1]
>   iCol = Split(Last.Text, "_")[2]
>
> End
>
>
>
> > The problem is that it only works with a button
> > If I fill the cell with a check box
> > It does not respond to a click event
> >
>
> Oh it has lots of problems if you want to make it do more than it has been
> designed for.
> I don't get why you even need it as there are plenty of ways to keep track
> of the buttons row/col data. As mentioned above.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.gambas-basic.org/pipermail/user/attachments/20230302/d18c9c65/attachment-0001.htm
> >
>
> ------------------------------
>
> Message: 4
> Date: Thu, 2 Mar 2023 16:51:54 +0000
> From: Bruce Steers <bsteers4 at gmail.com>
> To: Gambas Mailing List <user at lists.gambas-basic.org>
> Subject: Re: [Gambas-user] Event WebTable.Click
> Message-ID:
>         <
> CABuQYCB+orDrd8xZTpYGMWdX47yTNbXrUKAchs-Vnhq5MbitJQ at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> >
> >
> > Public Sub BUT_Click()
> >
> >   Dim iRow, iCol as Integer
> >   iRow = Split(Last.Text, "_")[1]
> >   iCol = Split(Last.Text, "_")[2]
> >
> > End
> >
>
> Oops, that should be Last.Name not Last.Text
>
>
> Public Sub BUT_Click()
>
>   Dim iRow, iCol as Integer
>   iRow = Split(Last.Name, "_")[1]
>   iCol = Split(Last.Name, "_")[2]
>
> End
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.gambas-basic.org/pipermail/user/attachments/20230302/4446bff7/attachment-0001.htm
> >
>
> ------------------------------
>
> Message: 5
> Date: Thu, 2 Mar 2023 19:01:52 +0000
> From: Bruce Steers <bsteers4 at gmail.com>
> To: Gambas Mailing List <user at lists.gambas-basic.org>
> Subject: Re: [Gambas-user] Event WebTable.Click
> Message-ID:
>         <CABuQYCART=
> fbYV9MCRC4K8a0Zd6UH7gKLhWjEWvt5tdZJa02Sw at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> On Thu, 2 Mar 2023 at 16:08, Mayost Sharon <sharon at 455.co.il> wrote:
>
> > Hello
> >
> > I know it's just for show
> > but
> > While I fill the cell with the button
> > data.control=WebButton
> > So when I click on the button that is in a certain cell I get an event
> of:
> > WebTable1_Click(Row As Integer, Column As Integer)
> > Then I can know from which row and which column the button is pressed
> > And it provides me with information on how to access a database to
> > retrieve the information I need
> >
> > The problem is that it only works with a button
> > If I fill the cell with a check box
> > It does not respond to a click event
> >
> > I am attaching the example again that shows what I mean
> >
>
> I'm attaching an example where buttons and checkboxes trigger
> WebTable1_Click event. all having Row and column data.
>
> the WebTable has 4 columns and puts a button/checkbox in each column.
>
> Did it like this...
> Non buttons (checkboxes) use the "ITEM" handler and on click they get the
> row/col from the name and raise the WebTable_Click event with the row/col
> data.
>
> There's always a way :)
> BruceS
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.gambas-basic.org/pipermail/user/attachments/20230302/9aa0aa38/attachment.htm
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
>
> ------------------------------
>
> End of User Digest, Vol 66, Issue 9
> ***********************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230303/3bff88b9/attachment.htm>


More information about the User mailing list