--
- name: test bearer token
hosts: localhost
tasks:
- name: use rest API to fetch data
uri:
headers:
Content-Type: application/json
access_token: "{{ bearer_token }}"
getting below error:
fatal: [localhost]: FAILED! => {"cache_control": "max-age=900", "changed": false,
"connection": "close", "content_length": "217", "content_type": "application/json;
charset=utf-8", "date": "Mon, 12 Feb 2024 02:07:09 GMT", "elapsed": 2,
"etag": "\"540e4ce8c3885eb9205fe234e50848c2\"", "json": {"error": {"message": "You may not have access to this repository or it no longer exists in this workspace. If you think this repository exists and you have access, make sure you are authenticated."},
"type": "error"}, "msg": "Status code was 404 and not [200]: HTTP Error 404: Not Found",
"redirected": false, "server": "envoy", "status": 404, "strict_transport_security": "max-age=31536000; includeSubDomains; preload",
"x_b3_spanid": "b3258d575680d880", "x_b3_traceid": "9e61c49c334aaafa", "x_cache_info": "caching",
"x_content_type_options": "nosniff", "x_dc_location": "Micros-3", "x_envoy_upstream_service_time": "43", "x_frame_options": "SAMEORIGIN", "x_render_time": "0.028755664825439453",
"x_request_count": "42", "x_request_id": "9e61c49c334aaafa", "x_served_by": "5f21d1d7a042",
"x_static_version": "2903ffcff137", "x_trace_id": "9e61c49c334aaafa", "x_usage_input_ops": "0", "x_usage_output_ops": "0",
"x_usage_system_time": "0.000036", "x_usage_user_time": "0.024417", "x_used_mesh": "False", "x_version": "2903ffcff137", "x_view_name": "bitbucket.apps.repo2.api.v20.repo.RepositoryHandler",
"x_xss_protection": "1; mode=block"}
- curl call works fine with the above used authorization bearer token.
how to use bearer token in uri module?
Thanks,
Mohan