dell / iDRAC-Redfish-Scripting

Python and PowerShell scripting for Dell EMC PowerEdge iDRAC REST API with DMTF Redfish
GNU General Public License v2.0
600 stars 278 forks source link

Redfish API error "msg": "Status code was 405 and not [200]: HTTP Error 405: Method Not Allowed", #194

Closed ashokbeh closed 2 years ago

ashokbeh commented 2 years ago

Hi, Using Ansible playbook trying to run a diagnostic test against the Dell poweredge server using iDRAC. However,on POST to initiate the diagnostic, encountered an error

"msg": "Status code was 405 and not [200]: HTTP Error 405: Method Not Allowed", "odata_version": "4.0", "redirected": false, "server": "Apache", "status": 405, "strict_transport_security": "max-age=63072000; includeSubDomains; preload", "url": "https://xxx.corp/redfish/v1/Managers/iDRAC.Embedded.1/DellLCService/Actions/DellLCService.RunePSADiagnostics", "x_frame_options": "DENY"

If we use curl to test the Redfish API it does not through the error.

curl -k -u "XXXX:XXXX" -v -H "Content-Type: application/json" -d "{\"RebootJobType\": \"GracefulRebootWithoutForcedShutdown\", \"RunMode\": \"Express\"}" https://xxxx.corp/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLCService/Actions/DellLCService.RunePSADiagnostics

{"@Message.ExtendedInfo":[{"Message":"The operation successfully completed.","MessageArgs":[],MessageArgs@odata.count:0,"MessageId":"IDRAC.2.4.SYS413","RelatedProperties":[],RelatedProperties@odata.count:0,"Resolution":"No response action is required.","Severity":"Informational"},{"Message":"Successfully Completed Request","MessageArgs":[],MessageArgs@odata.count:0,"MessageId":"Base.1.7.Success","RelatedProperties":[],RelatedProperties@odata.count:0,"Resolution":"None","Severity":"OK"}]}* Curl_http_done: called premature == 0

iDRAC version: 5.00.10.20 iDRAC 9 servergen 14G

Would appreciate if anyone can help.

texroemer commented 2 years ago

Hi @ashokbeh

Since this is an Ansible issue, can you please post this on Dell Ansible GitHub page:

https://github.com/dell/redfish-ansible-module/issues

Thanks Tex

anupamaloke commented 2 years ago

@ashokbeh, I guess you are not using the correct URL in the playbook:

"url": "https://xxx.corp/redfish/v1/Managers/iDRAC.Embedded.1/DellLCService/Actions/DellLCService.RunePSADiagnostics",

You need to use https://xxx.corp/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLCService/Actions/DellLCService.RunePSADiagnostics.

I was able to run the following playbook successfully:

  tasks:
  - name: run diagnostics
    ansible.builtin.uri:
      url: "https://{{ inventory_hostname }}/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLCService/Actions/DellLCService.RunePSADiagnostics"
      user: "{{ user }}"
      password: "{{ password }}"
      validate_certs: False
      force_basic_auth: yes
      method: POST
      headers:
        Accept: "application/json"
        Content-Type: "application/json"
        OData-Version: "4.0"
      body:
        RebootJobType: "GracefulRebootWithoutForcedShutdown"
        RunMode: "Express"
      body_format: json
      status_code: [200, 202]
    register: result
ashokbeh commented 2 years ago

Hi Anupamaloke.

Thank you it worked. However,have to find why /oem prefix has to be used against the API syntex given in https://www.dell.com/support/manuals/en-us/idrac9-lifecycle-controller-v4.x-series/idrac9_4.00.00.00_redfishapiguide_pub/supported-action--runepsadiagnostics?guid=guid-adf45a5b-a8e1-4c04-ab2f-f05fb012bf50&lang=en-us&emcs_t=S2h8ZW1haWx8dG9waWNfc3Vic2NyaXB0aW9ufEtYWkxRVk1OUDdMQTVUfDgxMTcyODV8U1VCU0NSSVBUSU9OU3xoSw

As advised by Tex, has posted in https://github.com/dell/redfish-ansible-module/issues

Thank you Tex for sharing the link.

Regards Ashok

anupamaloke commented 2 years ago

If I use "url": 'https://xxxx.corp/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLCService/Actions/DellLCService.RunePSADiagnostics", It works. This is against the syntax specified in iDRAC API web link. https://www.dell.com/support/manuals/en-us/idrac9-lifecycle-controller-v4.x-series/idrac9_4.00.00.00_redfishapiguide_pub/supported-action--runepsadiagnostics?guid=guid-adf45a5b-a8e1-4c04-ab2f-f05fb012bf50&lang=en-us&emcs_t=S2h8ZW1haWx8dG9waWNfc3Vic2NyaXB0aW9ufEtYWkxRVk1OUDdMQTVUfDgxMTcyODV8U1VCU0NSSVBUSU9OU3xoSw

@ashokbeh, In the API guide, the link mentioned is: /redfish/v1/Dell/Managers/<Manager-Id>/DellLCService/Actions/DellLCService.RunePSADiagnostics. See the part in blue. This is the old URI format/convention for the iDRAC Redfish OEM APIs. As per the Redfish standards (see here), these OEM end-points have now been standardized under /redfish/v1/Managers/<Manager-Id>/Oem/Dell with new iDRAC 5.x firmware versions. You can continue to use the old URI format on both iDRAC 4.xx.xx.xx and 5.xx.xx.xx firmware versions as backward compatibility is provided in 5.xx.xx.xx when using old URI formats. However, it is always recommend to upgrade to iDRAC 5.xx.xx.xx.