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:

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


- 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/"

became this:

        - name: Deploy SSH Key to New Project
          uri:
            url: "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

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a49efdb8-4f6e-4311-b856-33ec88b1fec7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to