HPE Morpheus Enterprise Software
1856403 Members
8296 Online
104112 Solutions
New Discussion

Re: Restapi task

 
Not applicable

Restapi task

I am trying to run python task but getting an error , same script is running manally from MD cli

5a70881dc1393555830e435a0e2c752761b99d6c.png

5 REPLIES 5
Not applicable

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.

Not applicable

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 ?

Not applicable

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 ?

KoreyG
HPE Pro

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!

cbunge
HPE Pro

Re: Restapi task

Are you defining your Additional packages on the task?