mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 18:02:05 +00:00
Merge pull request #4887 from alphashuro/patch-2
Add example for posting json content
This commit is contained in:
@@ -50,6 +50,20 @@
|
||||
##
|
||||
## echo client.postContent("http://validator.w3.org/check", multipart=data)
|
||||
##
|
||||
## You can also make post requests with custom headers.
|
||||
## This example sets ``Content-Type`` to ``application/json``
|
||||
## and uses a json object for the body
|
||||
##
|
||||
## .. code-block:: Nim
|
||||
## import httpclient, json
|
||||
##
|
||||
## let client = newHttpClient()
|
||||
## client.headers = newHttpHeaders({ "Content-Type": "application/json" })
|
||||
## let body = %*{
|
||||
## "data": "some text"
|
||||
## }
|
||||
## echo client.request("http://some.api", httpMethod = HttpPost, body = $body)
|
||||
##
|
||||
## Progress reporting
|
||||
## ==================
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user