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

1

2

I've been trying to access a site with REBOL using the site's API, but I'm having problems. The API call expects a custom header and a request in XML format. I've been trying with read/custom, but I'm unsure how to include the header, or what format it should take. The default header in system/options/cgi is an object, so I assume it should be an object, but where would you put it? (Adding to system/options/cgi hasn't worked.)

I'm guessing the code below is something like what I need...

http-custom-header: make object! [
    Content-Type: text/xml
    etc...
]

xml-request: {
    <?xml version="1.0" encoding="utf-8"?>
    <etc>etc...<etc>
}

site-URL: http://etc...

response: read/custom site-URL reduce ['post xml-request]

That won't work though as http-custom-header hasn't been put anywhere useful.

Am I on the right track? If so, where should the header go? Otherwise, what's a workable way to send an HTML header and request using REBOL?

Stenography answered 1/1, 2012 at 3:49 Comment(0)
S
3

I've figured it out. You just add 'header and a block (not an object) to the read/custom block. Thus...

http-custom-header: [
    Content-Type: text/xml
    etc...
]

xml-request: {
    <?xml version="1.0" encoding="utf-8"?>
    <etc>etc...<etc>
}

site-URL: http://etc...

response: read/custom site-URL reduce [
    'header http-custom-header
    'post xml-request
]
Stenography answered 1/1, 2012 at 12:9 Comment(1)
What are the other custom refinements for READ, header, post, any other?Lebaron

© 2022 - 2024 — McMap. All rights reserved.