Http.post

From MiniScript Wiki
Revision as of 00:35, 17 April 2021 by SicariusVelox (talk | contribs) (Created page with "In Mini Micro, the http.post function sends data to a URL using the POST method and returns the contents of the URL using the HTTP POST protocol. It supports text, im...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In Mini Micro, the http.post function sends data to a URL using the POST method and returns the contents of the URL using the HTTP POST protocol. It supports text, images, sounds, and raw binary data.

Arguments

Parameter Name Meaning
url URL of the web page or resource to fetch
data Data to post can be a string or a map
headers optional map of HTTP headers

Usage Notes

The type of the value returned depends on the MIME type reported by the server, as follows:

MIME Type MiniScript Type
image Image object
audio Sound object
text, javascript, xml, or json string
any other type RawData object

Example

The following example, typed on the Mini Micro command line posts form data, retrieves a response, and displays Hello World from the test site http://postman-echo.com.

request = http.post("http://postman-echo.com/post", {"data":"Hello World"})
request_data = json.parse(request)
request_data.form.data