CiscoDevNet / FMCAnsible

GNU General Public License v3.0
21 stars 25 forks source link

Invalid query parameter for the GETALL operation. #60

Open xibriz opened 9 months ago

xibriz commented 9 months ago

When trying to create an Access Rule in a spesific category we get the following error:

Server returned an error trying to execute createMultipleAccessRule operation. Status code: 400. Server response: Invalid query parameter for the GETALL operation.

Code to reproduce:

- name: Create access rule
  cisco.fmcansible.fmc_configuration:
    operation: createMultipleAccessRule
    path_params:
      domainUUID: "{{ domain_result.0.uuid }}"
      containerUUID: "{{ policy_result.0.id }}"
    query_params:
      category: "Test-category"
    data: "{{ access_rule }}"
    register_as: access_rule_result

The problem seems to be that the getAll check does not support the category parameter.

A workaround is to add bulk: true which makes the logic skip the equality check here: https://github.com/CiscoDevNet/FMCAnsible/blob/940a47531ff9b668d72fa36440a7b7d36c8b4225/plugins/module_utils/configuration.py#L389-L396

I have made the following temp fix in this function:

https://github.com/CiscoDevNet/FMCAnsible/blob/940a47531ff9b668d72fa36440a7b7d36c8b4225/plugins/module_utils/configuration.py#L323-L333

query_params = dict(query_params)
try:
    del query_params['category']
except:
    pass
url_params = {ParamName.QUERY_PARAMS: query_params, ParamName.PATH_PARAMS: dict(path_params)}

But a more permanent fix would be to check the API spesification and filter out only the allowed query params since the GET and POST could have different options.