Using JWPlatform API Get media: How do I access the response parameter "total"

Viewed 75

I'm sending this API request:

jwplatform_client = jwplatform.client.JWPlatformClient(mysecret)
response = jwplatform_client.Media.get(site_id=mysiteid,media_id = "", page=1,page_length = 10 )

According to the documentation, the response should have a parameter called "total".

How do I fetch that value?

1 Answers

The JSON response is available via the json_body attribute, but it also looks like you may want to switch to the list method for your use case, and note that the query params are defined in a single dict via the query_params kwarg.

The code would be as follows:

jwplatform_client = jwplatform.client.JWPlatformClient(mysecret)
response = jwplatform_client.Media.list(site_id=mysiteid, query_params={"page": 1, "page_length": 10})
total = response.json_body["total"]
...
Related