7

What is the simplest way of sending HTTP POST requests and getting response (in XML format for example) using only Rebol3?

Is there an equivalent of using read/custom in Rebol2, as it is done in this question?

How to send an HTTP post with a custom header using REBOL

And where should I be donwnloading my Rebol3 binaries from? I've not found a lot of documentation on that...

Community
  • 1
  • 1
dreamyToto
  • 131
  • 2

1 Answers1

6

The documentation at on Ports: Synchronous and Asynchronous Operations shows how to use both GET and POST. To summarize:

The default behavior is to assume the post data should be considered as application/x-www-form-urlencoded. (If you want to encode a block of ordinary Rebol data into that format, see %altwebform.r)

result: write http://www.rebol.com/cgi-bin/updata.r data 

If you need a custom header, then instead of passing a string you need to pass a block. Start it with the WORD! post followed by a block of Rebol-formatted key/value pairs, and then your data:

result: write http://www.rebol.com/cgi-bin/updata.r compose [
    post [
        Content-type: "text/x-rebol"
        ;-- other fields here
    ]
    (data)
]

The result will be in binary! and can be converted to string! to parse out any XML or whatever.

where should I be downloading my Rebol3 binaries from?

You should download binaries from http://www.rebolsource.net/

Graham Chiu
  • 4,856
  • 1
  • 23
  • 41
  • Thanks a lot, Graham. Tested at office with real SOAP web services. Amazing how it is simple ! – dreamyToto Oct 07 '13 at 20:36
  • This also works in Rebol 2 ```read/custom url compose [post (d) [Content-Type: "text/xml" ] ]``` Note that ```read/custom url compose [post (d) header [Content-Type: "text/xml" ] ]``` doesn't work. – endo64 Nov 18 '16 at 14:01