diff --git a/examples/README.md b/examples/README.md index 6bb22b35..3331e4b2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -656,6 +656,25 @@ response = service.post_document(db='products', document=products_doc).get_resul print(response) ``` +### [Example request as a stream](snippets/postDocument/example_request_as_a_stream.py) + +[embedmd]:# (snippets/postDocument/example_request_as_a_stream.py) +```py +# section: code +from ibmcloudant.cloudant_v1 import Document, CloudantV1 + +service = CloudantV1.new_instance() + +with open("products_doc.json", "rb") as products_doc: + response = service.post_document( + db='products', + document=products_doc_binary, + content_type="application/json" + ).get_result() + +print(response) +``` + ## putDatabase _PUT `/{db}`_ diff --git a/examples/snippets/postDocument/example_request_as_a_stream.py b/examples/snippets/postDocument/example_request_as_a_stream.py new file mode 100644 index 00000000..879ddbee --- /dev/null +++ b/examples/snippets/postDocument/example_request_as_a_stream.py @@ -0,0 +1,13 @@ +# section: code +from ibmcloudant.cloudant_v1 import Document, CloudantV1 + +service = CloudantV1.new_instance() + +with open("products_doc.json", "rb") as products_doc: + response = service.post_document( + db='products', + document=products_doc_binary, + content_type="application/json" + ).get_result() + +print(response)