VMWare vCenter DVS info

Hi,
I am new to ansible and am trying to create a playbook to read the port groups on a DVS in vcenter. So far all I have tried is not working.
We are running vCenter 8 so I think we need to use REST API.
Can anyone using ansible and vcenter provide me an example of a working playbook so I can compare to mine and see where I am going wrong?
Thanks

This should do the trick:

 tasks:
    - name: Get DVS port groups
      community.vmware.vmware_dvs_portgroup_info:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        validate_certs: false
        dvswitch_name: "{{ dvswitch_name }}"
      register: portgroups

    - name: Print port group info
      debug:
        var: portgroups.portgroups

https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_dvs_portgroup_info_module.html