Forum OpenACS Q&A: Re: Res: Re: http requests with XoTCL

Collapse
Posted by Stefan Sobernig on
Sorry, I had the idea to rewrite it and got stuck at the beginning. so the complete example should read as:
set request [::xo::HttpRequest new \
-content_type "text/plain" \
-url $url \
-post_data "your payload" \
-request_header_fields [list _fieldname_ _fieldvalue_]]
$request set data

The above example yields a POST request, simply by adding a non-empty value to "-post_data".

A GET request would look like the following:

set url "http://localhost:8000/xosoap/services/";
set request [::xo::HttpRequest new \
-content_type "text/html" \
-url [export_vars -base $url {{s badge}}]]
$request set data

The subtle difference is setting post_data or not! Whether you format the post or query string data in a "parameter'ish" way, does not make a difference.

Collapse
Posted by Tom Jackson on
Wow, that is pretty non-intutitive. How do you do a HEAD or PUT?