# ansible git uri

**URL:** <https://forum.ansible.com/t/ansible-git-uri/29429>\
**Category:** Ansible Project\
**Created:** [January 13, 2019, 12:20am UTC](https://forum.ansible.com/t/ansible-git-uri/29429 "2019-01-13T00:20:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JS11](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@JS11](https://forum.ansible.com/u/JS11)\
**Post date:** [January 13, 2019, 12:20am UTC](https://forum.ansible.com/t/ansible-git-uri/29429/1 "2019-01-13T00:20:11Z")

</div>

Hello

I need to run the following command using ansible:

`curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --header "Content-Type: application/json" --data '{"title": "My deploy key", "key": "ssh-rsa AAAA...", "can_push": "true"}' "https://gitlab.example.com/api/v4/projects/5/deploy_keys/"`

I can do most part of it using the git uri module, but was wondering how I can process the “–data” part of it ?

This is what I have so far:

`

- name: Deploy SSH Key to New Project  
uri:  
url: “{{ gitlab\_api\_url }}/projects/{{ new\_project\_id }}/deploy\_keys/”  
method: POST  
headers:  
PRIVATE-TOKEN: “{{ gitlab\_private\_token }}”  
Content-Type: application/json  
status\_code: 201  
`

Many thanks in advance!

Regards  
JS

---

<div class="post-metadata">

**Author:** ![JS11](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@JS11](https://forum.ansible.com/u/JS11)\
**Post date:** [January 14, 2019, 9:26am UTC](https://forum.ansible.com/t/ansible-git-uri/29429/2 "2019-01-14T09:26:56Z")

</div>

Hello

Just wanted to let you know this has now been solved. Did not realise --data could be passed in as the body.

E.g from SO:

```auto
curl -k -X POST https://mylink/action -d username=admin

```

```auto
- uri:
    url: https://your.form.based.auth.example.com/index.php
    method: POST
    body: "name=your_username&password=your_password&enter=Sign%20in"
    status_code: 302
    headers:
      Content-Type: "application/x-www-form-urlencoded"
  register: login

```

`body` is similar to `--data`.

So in my case,

`  
curl --request POST --header “PRIVATE-TOKEN: \<your\_access\_token\>” --header “Content-Type: application/json” --data ‘{“title”: “My deploy key”, “key”: “ssh-rsa AAAA…”, “can\_push”: “true”}’ “[https://gitlab.example.com/api/v4/projects/5/deploy\_keys/](https://gitlab.example.com/api/v4/projects/5/deploy_keys/)”

`

became this:

`

- name: Deploy SSH Key to New Project  
uri:  
url: “[https://gitlab.example.com/api/v4/projects/5/deploy\_keys/](https://gitlab.example.com/api/v4/projects/5/deploy_keys/)”  
method: POST  
body\_format: json  
body:  
title: “My deploy key”  
key: “ssh-rsa AAAA…”  
can\_push: “true”  
headers:  
PRIVATE-TOKEN: “{{ gitlab\_private\_token }}”  
Content-Type: application/json  
status\_code: 201  
`

Regards  
Jinal
