- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise Software
- >
- Re: Restapi task
Categories
Company
Local Language
Forums
Discussions
- Integrity Servers
- Server Clustering
- HPE NonStop Compute
- HPE Apollo Systems
- High Performance Computing
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp Software
Knowledge Base
Discussions
Forums
Discussions
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
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
04-10-2023 08:51 AM
04-10-2023 08:51 AM
Restapi task
I am trying to run python task but getting an error , same script is running manally from MD cli
- Tags:
- API
- automation
- Tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 09:24 AM
04-10-2023 09:24 AM
Re: Restapi task
You can use a workflow and task results to do that. This link has some additional context for that: Task Results — Morpheus Docs documentation.
Just make sure you are only outputting what you want to be read in the next task and it is in the proper format (ie. JSON)
Just to add onto the original question, python tasks run in a fresh virtual environment, so you need to put any additional packages into the tasks options to make sure they are installed when you run the task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 09:09 AM
04-10-2023 09:09 AM
Re: Restapi task
Ahh , got it , its working now , how to pass print command here , i want to run print(requests) but i see empty screen
i use GET to fetch some information , or POST to create , both task needs to return some output which i need to pass in other task input , how is it possible ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 09:36 AM
04-10-2023 09:36 AM
Re: Restapi task
I have already selected json as result type but i see no information , where can i check the Result is published or not ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 11:07 AM
04-10-2023 11:07 AM
Re: Restapi task
Hi @Paul_B,
Here is an example I created similar to your code:
import requests
api_url = "https://catfact.ninja/facts"
response = requests.get(api_url)
print(response.json())
This is the resulting data output:
Here is the configuration of the task I made:
You should see the results in the output in Morpheus, otherwise, the data will most likely not be available to the results variable.
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 08:54 AM
04-10-2023 08:54 AM
Re: Restapi task
Are you defining your Additional packages on the task?