Skip to content

_next method creates a HTTP request with wrong content-length header #1403

@schweikert

Description

@schweikert

Using google-api-python-client 2.2.0 and the GCP monitoring API, I received an error when retrieving the second page of a projects.timeSeries.query call:

can't fetch data, reason: Invalid JSON payload received. Unexpected end of string. Expected an object key or }.

Turns out that the content-length header is wrong and doesn't match with the body with the additional pageToken field.

The problem is in https://github.com/googleapis/google-api-python-client/blob/master/googleapiclient/discovery.py#L1285: the body is replaced, but the content-length stays the same because it is only updated at Request object creation time. I will prepare a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions