Difference between revisions of "Http.post"
Jump to navigation
Jump to search
(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...") |
m (added needed import statement.) |
||
Line 34: | Line 34: | ||
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. | 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. | ||
− | <ms>request = http.post("http://postman-echo.com/post", {"data":"Hello World"}) | + | <ms>import "json" |
+ | request = http.post("http://postman-echo.com/post", {"data":"Hello World"}) | ||
request_data = json.parse(request) | request_data = json.parse(request) | ||
request_data.form.data | request_data.form.data |
Latest revision as of 01:06, 17 April 2021
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