Skip to content

Commit 975d603

Browse files
cloudant-sdks-automationricellis
authored andcommitted
docs(generated): known issue for application/json attachments
Generated SDK source code using: - Generator version 3.110.0 - Specification version 1.0.0-dev0.1.33 - Automation (cloudant-sdks) version 095458f
1 parent 9f4391a commit 975d603

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

KNOWN_ISSUES.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,26 @@ client = CloudantV1.new_instance(service_name="YOUR_SERVICE_NAME")
143143
client.set_enable_gzip_compression(False)
144144
...
145145
```
146+
147+
### Attachments with `content-type: application/json`
148+
149+
Calling [`get_attachment`](https://ibm.github.io/cloudant-python-sdk/docs/latest/apidocs/ibmcloudant/ibmcloudant.cloudant_v1.html#ibmcloudant.cloudant_v1.CloudantV1.get_attachment)
150+
typically returns a `DetailedResponse` with `BinaryIO` result.
151+
For attachments uploaded with a `content-type: application/json`
152+
header or as a `.json` file in the dashboard then calls to `get_attachment`
153+
return a `DetailedResponse` with, for example, a `dict` result for a JSON
154+
object.
155+
The JSON is automatically loaded by the underlying SDK core
156+
and client to the default Python object types.
157+
158+
To get a `BinaryIO` result with an `application/json` attachment
159+
pass `stream=True` on the `get_attachment` request.
160+
161+
```python
162+
json_attachment: bytes = service.get_attachment(
163+
db='products',
164+
doc_id='1000042',
165+
attachment_name='product_details.json',
166+
stream=True
167+
).get_result().content # content bytes that can be decoded
168+
```

0 commit comments

Comments
 (0)