Question

I'm trying to write a Gnome program in Javascript. HTTP requests are done with a library called Soup, and GET requests start with something like:

msg = Soup.Message.new('GET', self.url) ...

Examples for GET requests are all over the net, but how to do a POST request?

Was it helpful?

Solution

Based on our chat conversation, this code will work:

msg = Soup.Message.new('POST', self.url);
var POSTparams = 'try=this';
msg.set_request ('application/x-www-form-urlencoded', 2, POSTparams, POSTparams.length);

The syntax seems to be:

msg.set_request('MIME type', (2), 'params=here', 'params=here'.length);

This answer was also based on the following:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top