# Issue with Ansible URI module execution for Spectrum API

**URL:** <https://forum.ansible.com/t/issue-with-ansible-uri-module-execution-for-spectrum-api/38609>\
**Category:** Ansible Project\
**Created:** [December 1, 2023, 8:05pm UTC](https://forum.ansible.com/t/issue-with-ansible-uri-module-execution-for-spectrum-api/38609 "2023-12-01T20:05:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![premkumar\_G](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@premkumar\_G](https://forum.ansible.com/u/premkumar_G)\
**Post date:** [December 1, 2023, 8:05pm UTC](https://forum.ansible.com/t/issue-with-ansible-uri-module-execution-for-spectrum-api/38609/1 "2023-12-01T20:05:26Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [December 4, 2023, 4:24pm UTC](https://forum.ansible.com/t/issue-with-ansible-uri-module-execution-for-spectrum-api/38609/2 "2023-12-04T16:24:28Z")

</div>

We need some more info/context:

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

And what is Postman?

---

<div class="post-metadata">

**Author:** ![premkumar\_G](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@premkumar\_G](https://forum.ansible.com/u/premkumar_G)\
**Post date:** [December 5, 2023, 1:23pm UTC](https://forum.ansible.com/t/issue-with-ansible-uri-module-execution-for-spectrum-api/38609/3 "2023-12-05T13:23:36Z")

</div>

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](http://www.ca.com/spectrum/restful/schema/request)”

xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”

xsi:schemaLocation="[http://www.ca.com/spectrum/restful/schema/request](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](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](http://www.ca.com/spectrum/restful/schema/response) total-models=]([http://www.ca.com/spectrum/restful/schema/response](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?
