Merge pull request #4887 from alphashuro/patch-2
Add example for posting json content
This commit is contained in:
commit
b77fb67fee
1 changed files with 14 additions and 0 deletions
|
|
@ -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
|
||||
## ==================
|
||||
##
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue