HTTPSocket POST Method

I’m aware of how to use a dictionary to fill inn fields in a form like this:

// create and populate the form object form = New Dictionary form.Value("firstname") = "Bob" form.Value("lastname") = "Brown"

The problem is that I don’t have a form to fill but still need to use the POST method.
I will use it to set values on a Obix server.
when I use other tools like the chome browser plugin “Simple REST Client” to POST whatever I like.

I need to POST <real val ="34.7" /> To http://localhost/obix/config/Mappe/Verdi/set

And this is the simplest example, I will have to POST a lot of XML like formatted strings to URL’s on the server.

My code now:

Dim form as new Dictionary Dim http as new HTTPSocket form.Value("xxxxxxx") ="<real val=""2.67"" />" ' What shold "xxxxxxx" be replaces with ??? http.SetFormData(form) http.post("http://localhost/obix/config/Mappe/Verdi/set/")

How to solve this ?

Instead of using a dictionary with SetFormData, you could try something like this, which posts the xml, without a name:

http.SetRequestContent("<real val=""2.67"" />","application/x-www-form-urlencoded") http.post("http://localhost/obix/config/Mappe/Verdi/set/")

Let me know if it worked.

Thanks !

Hello guys , any update on this ? im running XOJO 2014R3 and it seems that im getting some errors, I have to use HTTP.Post for an API and to pass it as a JSON, in the post part i have only dictionary so im doing for now d.Value("files") = "JSON String" but it seems that on the other end im not getting anything, any ideas ? it is working the url part but the SetFormData(d) it reaches empty on the server side.

Thanks

Did you try SetRequestContent as suggested?

Thanks Greg,

I found that in the meantime and it seems to be working ok .