cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2149
Views
2
Helpful
1
Replies

XML API issue with CIMC (v3.0)

knoppgary
Level 1
Level 1

I have 2 UCS C240 M4SX servers. They are each running a different CIMC version.   Although they both have XML API enabled, I'm unable to login into the server with the later CIMC version v3.0(3a).     Below is a simple script showing what happens.    I have tried later versions of python too.    Any idea whats happening and how to solve?

1) sdot-c240-0041   v2.0(10b)

2) sdot-c240-0061   v3.0(3a)

################

## Python script

################

#!/usr/software/bin/python2.7.5

import requests

requests.packages.urllib3.disable_warnings()

for server in ["sdot-c240-0041-cimc", "sdot-c240-0061-cimc"]:

    print(server + ":")

    url_api = "https://" + server + "/nuova"

    data = "<aaaLogin inName='admin' inPassword='password'></aaaLogin>"

    r = requests.post(url_api,data=data,verify=False)

    print("STATUS: " + str(r.status_code))

    print(r.headers)

    print(r.text)

################

## RESULTS

################

> ./p1.py

sdot-c240-0041-cimc:

STATUS: 200

{'Content-length': '187', 'Keep-Alive': 'timeout=60, max=2000', 'Server': 'Mbedthis-Appweb/2.4.2', 'Connection': 'keep-alive', 'Date': 'Fri, 12 Jan 2018 18:52:35 GMT', 'X-Frame-Options': 'SAMEORIGIN', 'Content-type': 'application/soap+xml;charset=UTF-8'}

<aaaLogin cookie="" response="yes" outCookie="1515783155/723d0d81-6299-1299-801a-720c6fc63d84" outRefreshPeriod="600" outPriv="admin" outSessionId="45" outVersion="2.0(10b)"> </aaaLogin>

sdot-c240-0061-cimc:

STATUS: 400

{'Date': 'Fri, 12 Jan 2018 11:53:12 GMT', 'Content-Length': '0', 'Server': 'Monkey'}

1 Accepted Solution

Accepted Solutions

jomcdono
Cisco Employee
Cisco Employee

Hi Gary,

The 3.0 firmware version http process that is listening for XML API requests requires that 'Content-Type' be specified in the header of the http request

This code should work for you on the 3.0 firmware, it may work on the 2.x as well.  Hope this helps.

Regards,

John

################

## Python script

################

#!/usr/software/bin/python2.7.5

import requests

requests.packages.urllib3.disable_warnings()

for server in ["sdot-c240-0041-cimc", "sdot-c240-0061-cimc"]:

    print(server + ":")

    url_api = "https://" + server + "/nuova"

    data = "<aaaLogin inName='admin' inPassword='password'></aaaLogin>"

    headers = {'Content-Type':'application/xml'}

    r = requests.post(url_api,data=data,verify=False,headers=headers)

    print("STATUS: " + str(r.status_code))

    print(r.headers)

    print(r.text)

View solution in original post

1 Reply 1

jomcdono
Cisco Employee
Cisco Employee

Hi Gary,

The 3.0 firmware version http process that is listening for XML API requests requires that 'Content-Type' be specified in the header of the http request

This code should work for you on the 3.0 firmware, it may work on the 2.x as well.  Hope this helps.

Regards,

John

################

## Python script

################

#!/usr/software/bin/python2.7.5

import requests

requests.packages.urllib3.disable_warnings()

for server in ["sdot-c240-0041-cimc", "sdot-c240-0061-cimc"]:

    print(server + ":")

    url_api = "https://" + server + "/nuova"

    data = "<aaaLogin inName='admin' inPassword='password'></aaaLogin>"

    headers = {'Content-Type':'application/xml'}

    r = requests.post(url_api,data=data,verify=False,headers=headers)

    print("STATUS: " + str(r.status_code))

    print(r.headers)

    print(r.text)

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: