Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}`_
Expand Down
13 changes: 13 additions & 0 deletions examples/snippets/postDocument/example_request_as_a_stream.py
Original file line number Diff line number Diff line change
@@ -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)