-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to access the response headers? #171
Comments
Have you tried accessing the response from the executor? We have a property there: tapioca-wrapper/tapioca/tapioca.py Lines 209 to 212 in edcbe11
So To get the headers: |
@fjsj Thanks a lot. This is a good candidate for a new Cookbook section in the documentation. The current documentation is neither nearly clear nor straightforward on that particular subject. |
Anyone who has the same doubts, this is a 100% working example. from tapioca import TapiocaAdapter, generate_wrapper_from_adapter, JSONAdapterMixin
RESOURCE_MAPPING = {}
class FooBarClientAdapter(JSONAdapterMixin, TapiocaAdapter):
api_root = 'https://run.mocky.io'
resource_mapping = RESOURCE_MAPPING
FooBarClientClass = generate_wrapper_from_adapter(FooBarClientAdapter)
tapioca_client = FooBarClientClass()
url = "https://run.mocky.io/v3/927b0e28-7ec2-44fc-ab3a-d4bd386ad130"
tapioca_client_executor = tapioca_client._wrap_in_tapioca_executor(url)
new_tapioca_client_class = tapioca_client_executor.get(params={'page': 1})
new_tapioca_client_executor = new_tapioca_client_class()
print(new_tapioca_client_executor.response.headers) |
Agreed @luzfcb , I'll leave the issue open due to that. Please feel free to open a PR for this additional documentation. |
Hi, I'm maintaining an existing application from a customer and there is an API client implementation of an external service that is implemented using tapioca-wrapper (v1.4.2). The external service now includes some headers in the response of each request and I need to perform different actions depending on the value that specific headers have.
Is there an official way to access the raw response object (not only the response body) from the
TapiocaClient
orTapiocaClientExecutor
?From the example below, how to access the response HEADERS from the
tapioca_client
instance,tapioca_client_executor
instance, or from the result object of theget()
method call?The text was updated successfully, but these errors were encountered: