Http.post

From MiniScript Wiki
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.

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