diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2016-10-12 16:33:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 16:33:59 +0200 |
commit | b77fb67fee2aca5dabbcfb6aff8cef0607ede9d0 (patch) | |
tree | 708c173d167e0d0f094c37cffb1d410d25bf4355 | |
parent | e6ff6dd9c89b3156fe50f61f6a28bcaba4aca91c (diff) | |
parent | 72b15678a1f66a8683034e30fefa51969a7ac4d5 (diff) | |
download | Nim-b77fb67fee2aca5dabbcfb6aff8cef0607ede9d0.tar.gz |
Merge pull request #4887 from alphashuro/patch-2
Add example for posting json content
-rw-r--r-- | lib/pure/httpclient.nim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 4404a9426..bfeb9a52e 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -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 ## ================== ## |