HTTPSocket.Post delivers no content

Hi guys, hope someone can help me, trying for 2 days now and read through all the questions regarding HTTPSocket here in the forum.

I’ve written a small app which should POST two values to a local HTTP server. If I use my own browser it works perfectly and the HTTP server can read both value (id and option). Here’s the URL:

If I use the chrome extension RestClient the same success, the Http server can read both value.

If I now try the same with my program, both values are undefined (on the server side). My code is as follows:

[code] Dim form As New Dictionary
Dim HTTPSocket1 As New HTTPSocket
Dim statuscode As Int16

sLine = “http://127.0.0.1:3000?id=123456&option=789
form.Value(“Line”) = sLine

Dim result As String
Dim InternetHeadersValue As InternetHeaders

InternetHeadersValue = HTTPSocket1.RequestHeaders
InternetHeadersValue.AppendHeader (“Content-Type”, “application/x-www-form-urlencoded”)
InternetHeadersValue.AppendHeader (“DNT”, “1”)
InternetHeadersValue.AppendHeader (“Accept-Encoding”, “gzip,deflate,sdch”)
InternetHeadersValue.AppendHeader (“Origin”, “chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo”)
InternetHeadersValue.AppendHeader (“User-Agent”, “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102 Safari/537.36”)
InternetHeadersValue.AppendHeader (“Accept-Charset”, “UTF-8”)

HTTPSocket1.SetFormData(form)

result = HTTPSocket1.Post(sLine,0)
statuscode = HTTPSocket1.HTTPStatusCode
If statuscode <> 200 Then
MsgBox ("Error: " + Str(statuscode))
End

Return TRUE[/code]

Please note that I tried already to set the InternetHeader exactly as to what the chrome extension is doing as well. Only “Accept-Charset” was added as the last try but also that didn’t do any change to the code not doing what it should do.

What am I doing wrong?

Thanks in advance,

Andreas

You don’t add the headers to HTTPSocket1, you add them to InternetHeadersValue, which is not connected to HTTPSocket1.

I add the headers like this:

Also change the URL from http://127.0.0.1:3000?id=123456&option=789 to http://127.0.0.1:3000/?id=123456&option=789

Thanks Ashot, adding the backslash solved it, my bad. Just one small correction though to the first part of your answer, when I run my code I can clearly see that with the Append.Header method I’m adding the header of HTTPSocket1.

Please see also this line of code executed before:

InternetHeadersValue = HTTPSocket1.RequestHeaders

[quote=64529:@Ashot Khachatryan]You don’t add the headers to HTTPSocket1, you add them to InternetHeadersValue, which is not connected to HTTPSocket1.

I add the headers like this:

[/quote]