Skip to content

request_rest improvement #79

@fostimus

Description

@fostimus

From a customer:

A potential improvement in request_rest.

Currently, if you pass a fully-qualified URL (like a downloadURL) to self.rest_client.get(...), it gets incorrectly prepended to the base URL — resulting in broken requests like:

https://app.useanvil.com/api/v1/https://app.useanvil.com/api/...

This behavior appears to come from logic that blindly joins self.get_url() with url, even when url is already complete.
To work around this, we’re currently using the internal client directly:

# Current workaround
byte_data = self.api_client.client.request(method="GET", url=download_url)

Ideally, we’d like to use the request_rest() interface:

# Desired usage (currently causes double-url issue)
byte_data = self.rest_client.get(url=download_url)

Also worth noting — it looks like request_rest() accepts an options object that doesn’t get used. It could be helpful to allow something like an absolute_url=True flag there (or an internal check for url.startswith("http")) to handle full URLs gracefully.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions