Issue with Ansible URI module execution for Spectrum API

Hello Ansible Community,

I’m currently facing an issue while trying to execute a Spectrum API call using the Ansible URI module. The API call is working fine in Postman, but when I try to replicate it in Ansible, I encounter problems.

Here’s a simplified version of my Ansible playbook:

We need some more info/context:

What problems?
What is the error?
What is the output?

And what is Postman?

I have two APIs related to CA Spectrum. The first API puts network devices in maintenance mode, and the second API is used to find the model MH value based on a device name.

API Details:

  1. Maintenance Mode API:

URL: http://CAserver:portnumber/spectrum/restful/model/0xa0000fa0?attr=0x1295d&val=false

Issue: I need to find the correct value (e.g., 0xa0000fa0) to replace in the URL.

  1. Find Model API:

URL: http://CAserver:portnumber/spectrum/restful/models/

Body:

<rs:model-request throttlesize=“5”

xmlns:rs=“http://www.ca.com/spectrum/restful/schema/request

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance

xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request …/…/…/xsd/Request.xsd ">

rs:target-models

rs:models-search

<rs:search-criteria

xmlns=“http://www.ca.com/spectrum/restful/schema/filter”>

YourActualDeviceName

</rs:search-criteria>

</rs:models-search>

</rs:target-models>

<rs:requested-attribute id=“0x1006e” />

<rs:requested-attribute id=“0x129fa” />

</rs:model-request>

Issue: I’ve received an XML response, and I need to extract the ‘mh’ value from it to use in the Maintenance Mode API.

XML Response:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<model-response-list xmlns=[http://www.ca.com/spectrum/restful/schema/response total-models=](http://www.ca.com/spectrum/restful/schema/response
total-models=)“156” throttle=“156” error=“EndOfResults”>

192.168.74.63

192.168.74.63

Request for Help:

  1. How can I extract the ‘mh’ value from the XML response using Ansible?

  2. Once I have the ‘mh’ value, how can I dynamically replace it in the Maintenance Mode API URL?