Problem using API (total_count is required property)


#1

The problem has disappeared. Everything working fine (except that I could not remove this post completely) :slight_smile:

[details=Original Post]When using the API some results can not be retrieved, and the error message contains the phrase: ValidationError: ‘total_count’ is a required property.

This error only occurs selectively on some intermediate pages. See example code below:

from bravado.client import SwaggerClient
OPENTRIALS_API_SPEC = 'http://api.opentrials.net/v1/swagger.yaml’
config = {‘use_models’: False}
client = SwaggerClient.from_url(OPENTRIALS_API_SPEC, config=config)

# some queries appear to work
result = client.trials.searchTrials(q=‘Lapatinib’, page=10, per_page=10).result()

# presently there seem to be 670 records
print(result[‘total_count’])

# others queries fail
result_failing = client.trials.searchTrials(q=‘Lapatinib’, page=42, per_page=10).result()
# While the error log is several screens long, one potential hint is:
# ValidationError: ‘total_count’ is a required property

# note a: other queries with a higher page number might work:
result_working = client.trials.searchTrials(q=‘Lapatinib’, page=45, per_page=10).result()

# note b: The above has been observed on 16-10-30, and the specific numbers might change
# while the open trials database grows.[/details]