Server Management - Remote Server Management
cancel
Showing results for 
Search instead for 
Did you mean: 

REST API iLO5 - CURL POST always returns 'BAD REQUEST'

 
SOLVED
Go to solution
MFajt
Occasional Visitor

REST API iLO5 - CURL POST always returns 'BAD REQUEST'

Hi!

Could anyone show how to use curl to 'post' data via REST API to iLO5? Below is an example, I am able to get SNMP related data but when trying to modify it via POST it always returns BAD REQUEST.

Thanks!

 

1) .\curl.exe https://IP/redfish/v1/Managers/1/SnmpService/ -s -i --insecure -u user:pswd

HTTP/1.1 200 OK
Allow: GET, HEAD, POST, PATCH
Cache-Control: no-cache
Content-type: application/json; charset=utf-8
Date: Fri, 09 Aug 2019 06:40:36 GMT
ETag: W/"82DEEBBA"
Link: </redfish/v1/SchemaStore/en/HpeiLOSnmpService.json/>; rel=describedby
OData-Version: 4.0
Transfer-Encoding: chunked
X-Frame-Options: sameorigin
X_HP-CHRP-Service-Version: 1.0.3


2) .\curl.exe -s -i --insecure -X POST -H "Content-Type: application/json" -d '{"Location":"Test"}' -u user:pswd https://IP/redfish/v1/Managers/1/SnmpService/

HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Content-type: application/json; charset=utf-8
Date: Fri, 09 Aug 2019 06:41:55 GMT
ETag: W/"02C2D1BB"
OData-Version: 4.0
Transfer-Encoding: chunked
X-Frame-Options: sameorigin
X_HP-CHRP-Service-Version: 1.0.3

3 REPLIES 3
Highlighted
Suvamay
HPE Pro

Re: REST API iLO5 - CURL POST always returns 'BAD REQUEST'

Hello 

I would suggest you to go through the below link.

https://hewlettpackard.github.io/ilo-rest-api-docs/ilo5/

Thanks


Accept or Kudo
chrislee18a
Occasional Advisor
Solution

Re: REST API iLO5 - CURL POST always returns 'BAD REQUEST'

Try to do a PATCH instead of a POST.

If you get a MalformedJSON error. Check if you need to add "\" in front of double quote.

More explain on adding slash in front of double quotes

Chris

I am a HPE Employee.
MFajt
Occasional Visitor

Re: REST API iLO5 - CURL POST always returns 'BAD REQUEST'

Thanks a lot! That was exactly what was needed.

The working syntax below:

.\curl.exe -i --insecure -X PATCH -H "Content-Type: application/json" -d "{\"Location\":\"New location\"}" -u user:pswd -L https://{IP}/redfish/v1/Managers/1/SnmpService/

Milan