Hi,

I am trying to call bitbucket REST APIs with ansible.builtin.uri module 
using Authorization token like below.

--
- name: test bearer token
hosts: localhost

tasks:
- name: use rest API to fetch data
uri:
headers:
Content-Type: application/json
access_token: "{{ bearer_token }}"
url: https://api.bitbucket.org/2.0/repositories/mob1/test1

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", 
"url": "https://api.bitbucket.org/2.0/repositories/mob1/test1";, "vary": 
"authorization, cookie, user-context, Origin", "x_accepted_oauth_scopes": 
"repository", 
"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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7e168f34-8df5-4000-bd0f-7056c9b04e01n%40googlegroups.com.

Reply via email to