UNSOLVED

travelerdb

updated

4 years ago

T

travelerdb

10 Posts

0

900

June 6th, 2022 09:00

Error with api call to modify ntp settings on Unity

Using Ansible uri module to make api call to Unity and getting a 401 unauthorized response, however, the user I'm using is an admin.  Here are the headers I'm sending which includes a token from a prior task.  Anything I'm missing or another reason why it would come back and say it's not authorized?

- name: Set NTP on storage array
  uri:
  timeout: 300
  url: "https://{ { inventory_hostname }}/api/instances/ntpServer/0/action/modify"
  force_basic_auth: yes
  method: POST
  user: "{ { username }}"
  password: "{ { password }}"
  validate_certs: no
  body_format: json
  headers:
  Content-Type: "application/json"
  X-EMC-REST-CLIENT: true
  EMC-CSRF-TOKEN: "{ { token }}"
  body: "{ { ntp_body }}"
  environment:
  no_proxy: '*'
  register: result
  • DELL-Sam L

    Community Manager

    8056 Posts

    34380 Points

    777

    0

    Posted June 6th, 2022 16:00

    Hello travelerdb,

    Which unity system do you have and what is your current OE?

  • DELL-Sam L

    Community Manager

    8056 Posts

    34380 Points

    761

    0

    Posted June 7th, 2022 14:00

    Hello travelerdb,

    Looking at your error that you posted it is stating that there is an issue with the account that you are using.  I would double check your user name and password to ensure that it was entered correctly.

  • DELL-Sam L

    Community Manager

    8056 Posts

    34380 Points

    744

    0

    Posted June 8th, 2022 16:00

    Hello travelerdb,

    Let me look into this to see what I can find out.

  • travelerdb

    10 Posts

    783

    0

    Posted June 6th, 2022 09:00

    Here's the actual response... 

    "content": "\n\n401 Unauthorized\n\n

    Unauthorized

    \n

    This server could not verify that you\nare authorized to access the document\nrequested. Either you supplied the wrong\ncredentials (e.g., bad password), or your\nbrowser doesn't understand how to supply\nthe credentials required.

    \n\n"
  • travelerdb

    10 Posts

    767

    0

    Posted June 7th, 2022 03:00

    Hi @DELL-Sam L , 

    Here's info on the array...

    "api_version": "11.0",
    "model": "Unity 480F",
    "software_version": "5.1.2"

     

    Hope this helps

    Thanks!

  • travelerdb

    10 Posts

    747

    0

    Posted June 8th, 2022 11:00

    @DELL-Sam L -- the user I'm using is an ldap user which is an admin on the array.  Are there other permissions needed?  From what I can see, this boils down to what headers is the unity api expecting when the authentication is happening for a POST call.  In the previous task, I am successfully authenticating using basic auth and getting the EMC-CSRF-TOKEN which i'm adding as a header in the subsequent POST call, however, it seems the api is expecting something different.  So, if we can answer the question around what headers the api is expecting, that would probably solve it as it seems to be redirecting the call to /cas/login currently.