3

I found that there is a red command to download contents of a web page:

read https://trello.com/c/8p75OiSE/26-test-card.json

However, I have two problems (at least on Linux Mint):

  1. Trello's response differs for this request than it does for simply visiting this URL in a web browser (try it! it works fine in a browser).
  2. If I did need to add authorization headers (shouldn't for this public card), I don't see a way to do that.

It is even worse in Tio.run, but I'm pretty sure that is not a problem with the language itself but with Tio.run.

NH.
  • 2,240
  • 2
  • 23
  • 37
  • On point 1—I get the same response from Trello. Is it different perhaps as you're signed in to Trello in the browser? – rgchris Oct 13 '17 at 17:59
  • @rgchris you get an error response? I tried in private browsing too and it worked. – NH. Oct 13 '17 at 19:40
  • Here's some code to [talk to Trello in Rebol2](http://www.codeconscious.com/rebol/articles/basic-trello-interface.html), which may be of interest, but probably hasn't been checked for operation with recent Trello. – HostileFork says dont trust SE Oct 13 '17 at 20:26
  • @NH. No—I didn't get an error response. – rgchris Oct 13 '17 at 21:00
  • 1
    This shows a comparable issue https://stackoverflow.com/questions/31218141/trello-responds-invalid-key – sqlab Oct 14 '17 at 10:24

1 Answers1

3

WRITE, and more specifically WRITE/INFO should give you enough leverage to engage most APIs.

The most basic usage of WRITE returns the body of the HTTP response:

probe write http://some.resource/api/method "Some Data"

You can get the header of the response by adding /INFO:

probe write/info http://some.resource/api/method "Some Data"

And you can send different HTTP methods and headers using a BLOCK! as your WRITE argument:

probe write/info http://some.resource/api/method [
    put [Content-Type: "application/json"] {["Some Data"]}
]
rgchris
  • 3,698
  • 19
  • 19
  • For more help with `write`, check out [rebolek/http-tools](https://github.com/rebolek/red-tools/blob/master/http-tools.red) on Github. He also has REST API wrappers around Github and Gitter there. – Dave Andersen Oct 15 '17 at 01:30