Provides HTTP REST capabilities for Magic. More specifically this project provides the following 4 slots.
- [http.get] - Returns some resource using the HTTP GET verb towards the specified URL
- [http.delete] - Deletes some resource using the HTTP DELETE verb
- [http.post] - Posts some resources to some URL using the HTTP POST verb
- [http.put] - Puts some resources to some URL using the HTTP PUT verb
The [http.put] and the [http.post] slots requires you to provide a [payload], which will be pass to the
endpoint as a string. All 4 endpoints can (optionally) take a [token] arguments, which will be transferred as
a Bearer Authorization
token to the endpoint, in the HTTP Authorization header of your request.
Notice, if you want to have more control over your HTTP request, you can also explicitly add your own [header] collection, which will become the HTTP request's headers, where the header name is the name of the node, and its value is the value of the node. Below is a simple example of retrieving the document found at the specified URL, using a simple GET HTTP request, without neither a [token] nor [header] collection.
http.get:"https://google.com"
Both the POST and PUT slots, requires a [payload] argument, which becomes the body to the endpoint. Below is an example illustrating how to create a POST request, with a Bearer token to access the end resource.
http.post
token:qwerty_secret_JWT_token_goes_here
payload:some mumbo jumbo payload, typically JSON and not text though ...
Below is another example invoking DELETE with an explicit [headers] collection.
http.delete:"https://foo-url.com"
headers
Accept:application/zip
X-Foo:Bar-Header-Value