httpsocket.Post array?

Does anyone know how to ‘post’ an array of values? The reference guide shows simple form fields using a dictionary, but I’ve got a receiving side which expects a ‘selection list’. The format of the post is something like:

?cars[]=Saab&cars[]=Audi&cars[]=Volvo…

Can’t really use a dictionary, as there would only be one entry, for ‘cars[]’, rather than separate.

Dim Form as New Dictionary
Form.Value(“cars[]”) = “Saab”
Form.Value(“cars[]”) = “Audi”
myHttpSocket.SetFormData Form
result = myHttpSocket.Post(“some.webserver.com”,30)

I’m not exactly well-versed in this sort of thing, so figure an appeal for help is warranted.

Thanks,

Darryl

What is the square character here ? I doubt very much the server expects a non ASCII character.

That’s actually [ ] but doesn’t show nicely. It’s an array indicator, drawn from this StackExchange:

http://stackoverflow.com/questions/6243051/how-to-pass-an-array-within-a-query-string

[code]Three possible ways to send multi-value fields or arrays would be:

?cars[]=Saab&cars[]=Audi (Best way- PHP reads this into an array)
?cars=Saab&cars=Audi (Bad way- PHP will only register last value)
?cars=Saab,Audi (Haven’t tried this)
[/code]

I see. Like in JavaScript, but without the index. It shows much better when you format it as code.

You will have to build the parameters line.

Well the field names in a form may support brackets so you could try it with Xojo and hope it passes through.

I’m pretty ignorant on setting things up manually. Any pointers on how to build the parameters line manually?

Thanks for your help (both of you).

OK, after some experimenting, here’s what worked:

Dim notifySocket as New HTTPSecureSocket
Dim Form as new Dictionary
Dim result as String
notifySocket.SetFormData Form
notifySocket.SetRequestContent("cars[]=Saab&cars[]=Audi&cars[]=Volvo","application/x-form-urlencoded")
result = notifySocket.Post("my.url.com",30)

The result on the ‘other side’ was an array containing ‘Saab’,‘Audi’,‘Volvo’
An interesting point is that unless I used ‘SetFormData’, it wouldn’t work. Once I added that, even with an empty dictionary, things went well.