- Community Home
- >
- Software
- >
- HPE OneView
- >
- Power off server
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2022 04:45 AM - last edited on 09-07-2022 05:02 AM by support_s
09-06-2022 04:45 AM - last edited on 09-07-2022 05:02 AM by support_s
I'm trying to send a REST API call to a server to power it off, but getting back:
{"errorCode":"INVALID_JSON_DATA_TYPE","message":"Invalid JSON data type.","details":"The JSON sent in the request contained a unknown type where a different unknown type is required on line 1 near column 15.","messageParameters":[],"recommendedActions":["Correct the content of the JSON and retry the request."],"errorSource":null,"nestedErrors":[],"data":{}}
Just realized why I was getting that. I was using "off" instead of "Off." So, case is significant. Might be good to point out in the API reference what the exact allowed values are for powerState?
My working code is:
SERVER=my.fqdn
POWER=<On|Off>
ACTV=$(python -c "import urllib, sys; print urllib.quote(sys.argv[1])" "\"serverName = '${SERVER}'\"")
UUID=$(curl --insecure --silent \
--header "auth: ${sessionID}" \
--header "X-API-Version: ${currentVersion}" \
--request GET ${OneView}/rest/server-hardware?filter=${ACTV} | jq -r '.members[] | .uuid')
DATA='{"powerState":"'${POWER}'","powerControl":"MomentaryPress"}'
TASKURI=$(curl --insecure \
--header "content-type: application/json" \
--header "X-API-Version: ${currentVersion}" \
--header "auth: ${sessionID}" \
--include \
--data "${DATA}" \
--request PUT ${OneView}/rest/server-hardware/${UUID}/powerState | grep '^Location:' | awk '{ print $2})
echo "Can check the power off task at: ${TASKURI}"
Solved! Go to Solution.
- Tags:
- OneView
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 04:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 05:39 AM
09-07-2022 05:39 AM
Re: Power off server
Hello @BradV,
Thank you for sharing the info. We hope it'll help other community members.