Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
yoan
Explorer

SHOW-USERS CALL API result empty

Hello,

 

I'm having some issues with the show-users API call, which returns an empty result, whereas show-domains works fine.

Here's my code:



    - name: "[MDS] Send POST request to Check Point API for login"
      ansible.builtin.uri:
        url: "https://mdshost.test.local/web_api/login"
        method: "POST"
        headers:
          Content-Type: "application/json"
        body_format: json
        body:
          user: "admin"
          password: "wwwwwww"
        validate_certs: false
      register: _login_query_response
      failed_when: false
      delegate_to: localhost

    - name: "[MDS] Set the session ID for subsequent API calls"
      set_fact:
        _mds_sid: "{{ _login_query_response.json.sid }}"
        _mds_url: "{{ _login_query_response.json.url }}"
      when: _login_query_response.json != {}

    - name: "Send POST request to check If domains"
      ansible.builtin.uri:
        url: "{{ _mds_url }}/show-domains"
        method: "POST"
        headers:
          Content-Type: "application/json"
          X-chkp-sid: "{{ _mds_sid }} "
        body_format: json
        body:
          details-level: standard
        validate_certs: false
        status_code: 200
      ignore_errors: true
      register: _show_domain_response

    - name: "Send POST request to check If users"
      ansible.builtin.uri:
        url: "{{ _mds_url }}/show-users"
        method: "POST"
        headers:
          Content-Type: "application/json"
          X-chkp-sid: "{{ _mds_sid }} "
        body_format: json
        body:
          details-level: full
        validate_certs: false
        status_code: 200
      ignore_errors: true
      register: _show_users_response

 

Here's the output when i use ansible-playbook -vvv:

ok: [test] => {
    "changed": false,
    "connection": "close",
    "content_type": "application/json",
    "cookies": {},
    "cookies_string": "",
    "date": "Mon, 08 Jul 2024 09:36:20 GMT",
    "elapsed": 0,
    "invocation": {
        "module_args": {
            "attributes": null,
            "body": {
                "details-level": "full"
            },
            "body_format": "json",
            "ca_path": null,
            "client_cert": null,
            "client_key": null,
            "creates": null,
            "dest": null,
            "follow_redirects": "safe",
            "force": false,
            "force_basic_auth": false,
            "group": null,
            "headers": {
                "Content-Type": "application/json",
                "X-chkp-sid": "gergreggrgegrgegr"
            },
            "http_agent": "ansible-httpget",
            "method": "POST",
            "mode": null,
            "owner": null,
            "remote_src": false,
            "removes": null,
            "return_content": false,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": null,
            "status_code": [
                200
            ],
            "timeout": 30,
            "unix_socket": null,
            "unredirected_headers": [],
            "unsafe_writes": false,
            "url": "https://gergergreg:443/web_api/show-users",
            "url_password": null,
            "url_username": null,
            "use_gssapi": false,
            "use_proxy": true,
            "validate_certs": false
        }
    },
    "json": {
        "objects": [],
        "total": 0
    },
    "msg": "OK (unknown bytes)",
    "redirected": false,
    "server": "Jetty(9.2.9.v20150224)",
    "status": 200,
    "strict_transport_security": "max-age=31536000; includeSubDomains",
    "transfer_encoding": "chunked",
    "url": "https://gerger:443/web_api/show-users",
    "x_forwarded_host_port": "443",
    "x_frame_options": "SAMEORIGIN",
    "x_ua_compatible": "IE=EmulateIE8"
}

Did I make an error in my code?

0 Kudos
1 Reply
PhoneBoy
Admin
Admin

Please try making the API call directly (without Ansible).
mgmt_cli -r true show users
Documentation: https://sc1.checkpoint.com/documents/latest/APIs/#cli/show-users~v1.9.1

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events