Following redirects does not work in es-py
See original GitHub issueI tried my best to follow the documentation and code to figure out how to enable redirects for an ES client, but keep getting an HTTP 302 response for my request. Here is my code:
headers={'connection': 'keep-alive', 'redirects': True}
es = Elasticsearch([{'host': cluster, 'port': 80}], http_auth=(user, secret), scheme='http', headers=headers)
res = es.exists(index=myIndex, doc_type='test', id='ABCDEF1234')
Here is the error message I see:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/x-9GQQSZlO/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 76, in _wrapped
return func(*args, params=params, **kwargs)
File "~/x-9GQQSZlO/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 357, in exists
doc_type, id), params=params)
File "~/x-9GQQSZlO/lib/python2.7/site-packages/elasticsearch/transport.py", line 314, in perform_request
status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
File "~/x-9GQQSZlO/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 180, in perform_request
self._raise_error(response.status, raw_data)
File "~/x-9GQQSZlO/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 125, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.TransportError: TransportError(302, u'')
Based on the code in es-py GitHub under connection/http_requests.py, headers set this way below should have worked. I tried these variations below but without success.
headers={'connection': 'keep-alive', 'redirects': True}
headers={'connection': 'keep-alive', 'redirects': 'true'}
What am I missing ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Why browser do not follow redirects using XMLHTTPRequest ...
Simple GET requests using CORS are working just fine in Chrome and Firefox. Some method accept data via POST and return 303 code...
Read more >Postman always follows redirects, ignores setting ... - GitHub
I have moved to Postman for Linux which solved the problem for me. ... Settings > Interceptor > Automatically follow redirects is off....
Read more >OWA redirection doesn't work after installing November 2021 ...
Exchange Server admins can use the redirect rule to modify the redirect URL so that the error does not appear to users.
Read more >Redirections in HTTP - MDN Web Docs - Mozilla
HTTP redirects are the best way to create redirections, but sometimes you don't have control over the server. In that case, try a...
Read more >Using redirects - AWS Amplify Hosting
404 redirects occur when a request points to an address that doesn't exist. The destination page of a 404 is displayed instead of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@MarcDAFrame It’s built into the library already all you have to do is instantiate your connection using the requests transport class. https://elasticsearch-py.readthedocs.io/en/master/transports.html#transport-classes
@jarajapu Thanks for the issue.
Where did you find documentation about that header?
re using
scheme
I don’t think you should really worry about that. Just instantiate the object with a string of your cluster url.