- Community Home
- >
- Software
- >
- HPE OneView
- >
- getting error, but command works for changing serv...
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
Discussions
Discussions
Discussions
Forums
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
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-10-2020 05:38 AM
тАО09-10-2020 05:38 AM
The command is working, but I am getting a parse error: Invalid numeric literal at line 1, column 9
DATA='{"powerState":"Off","powerControl":"MomentaryPress"}'
curl --insecure \
--header "content-type: application/json" \
--header "X-API-Version: ${currentVersion}" \
--header "auth: ${sessionID}" \
--include \
--data "${DATA}" \
--request PUT ${OneView}/rest/server-hardware/{id}/powerState | jq -r '.'
The server is powering off, but I'm getting that error. If I change the powerState to On and apply, that works also, but with the same parse error. Anyone have a clue what could be wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2020 11:17 AM
тАО09-10-2020 11:17 AM
Re: getting error, but command works for changing server power state
This is an error within Bash, and your use of jq. I found a thread on this over on Stackoverflow. The HTTP response from this request will be either an HTTP Error (400-, 500- series code) or HTTP 202 for success. There will be no JSON response until you get the Location HTTP header for the async task from the HTTP 202 response. Otherwise, what are you trying to parse with jq in your pipeline?
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2020 11:53 AM
тАО09-10-2020 11:53 AM
Re: getting error, but command works for changing server power state
Hi Chris,
I have no idea.
It's my standard response when sending a command to the REST API. I'll remove it and see what messages I'm receiving. It is working. So, that part is good.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2020 11:56 AM
тАО09-10-2020 11:56 AM
Re: getting error, but command works for changing server power state
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2020 12:30 PM
тАО09-10-2020 12:30 PM
Re: getting error, but command works for changing server power state
No, totally my fault. I did not look at the specs close enough to notice it was not a json output. Sorry!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-11-2020 03:32 AM
тАО09-11-2020 03:32 AM
SolutionI fixed with:
DATA='{"powerState":"Off","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/{id}/powerState | grep '^Location:' | awk '{ print $2})
Can then check the status of the task with:
curl --insecure \
--header "X-API-Version: ${currentVersion}" \
--header "auth: ${sessionID}" \
--request GET ${OneView}${TASKURI} | jq -r '.'