1

I'd like to execute a simple POST request using libsoup. The api of the website i'd like to send data to requires only one field named 'content'. With curl i do this:

curl -si -F 'content=mycontent' http://mywebsite.org/api 

How can I do the same with libsoup?

En_t8
  • 7,595
  • 5
  • 20
  • 14

1 Answers1

2

Google probably does this better for you than me. Here is a link with the libsoup client basics. http://developer.gnome.org/libsoup/stable/libsoup-client-howto.html

From there you should try something similar to

guint status;
SoupMessage *msg;
const char * mycontent; //alloc and fill this with your data
msg = soup_message_new ("POST", "http://example.com/form.cgi");
soup_message_set_request (msg, "whatever content type here",
          SOUP_MEMORY_COPY, mycontent, strlen (mycontent));
status = soup_session_send_message (session, msg);
//error handling etc
snugglo
  • 259
  • 1
  • 5
  • Yes, I know this example, but I'm looking for something that could do the same of the curl option -i (which includes the HTTP-header in the output) – En_t8 Apr 16 '12 at 18:37
  • @En_t8 then if you by chance missed it there is the function `soup_message_headers_get_one (msg->response_headers,const char* header_name)` but there is no way of getting the headers in one call like curl's -i option. – snugglo Apr 16 '12 at 19:54