UNSOLVED

ErwinF

updated

6 years ago

E

ErwinF

1 Rookie

11 Posts

0

2727

May 26th, 2020 05:00

Python REST API Unity login

Hi Experts,

I am trying to write a Python code that login to the Unity and capture a few details. I do however had challenges capturing the token on response header EMC-CSRF-TOKEN.

What am I doing wrong on the below script?

headers = {
 
'Content-Type': 'application/json',
'Accept': 'application/json',
'Accept-Charset': 'utf-8',
'Accept-Encoding': 'gzip',
'Connection': 'Keep-Alive',
'Authorization': auth,
}

urllib3.disable_warnings(InsecureRequestWarning)

response = r.get('https://MYUNITYIP/api', headers=headers, verify=False)
response.raise_for_status()
token = response.headers.get('EMC-CSRF-TOKEN ')

 

  • DELL-Sam L

    Community Manager

    8056 Posts

    34380 Points

    2207

    0

    Posted May 27th, 2020 12:00

    Hello ErwinF,

    Here is a link to a KB that way help.  You will need to login in with your EMC account. https://dell.to/2M2Qvym

    Please let us know if you have any other questions.

  • vengle

    3 Posts

    1843

    0

    Posted November 23rd, 2020 11:00

    Did you ever get a python specific answer? I'm looking at the same task now and would love to see some example working python code to manage a session with a unity array.

  • 756

    0

    Posted June 17th, 2022 15:00

    This is an old topic, but I'm having the same problem. Does anyone have a working python3 script example to capture the token?

    Thank you
    Chris

  • Rainer_EMC

    6 Operator

    8645 Posts

    613

    0

    Posted July 11th, 2022 05:00

    maybe a look at the existingt Python libs could help

    https://github.com/ktelep/EMCUnity
    https://github.com/emc-openstack/storops