File fetching from cloud

I have a file in git repository,

and i want to map that file in python function node,

Can someone help me with this?

I think that would be:

/home/vcap/app/get_ticket.py

If you are using Node-RED on bluemix or any other cloud environment it’s useful to state that in your post.

Yes I'm on Node-RED on bluemix

Thank you nick it really did work but i get this error message,

image

Here is the script in that file,


import requests
import json

requests.packages.urllib3.disable_warnings()

apic_em_ip = "https://sandboxapicem.cisco.com/api/v1/ticket"

def get_token(url):

#Payload contains authentication information
payload = { "username": "******", "password": "*********" }

#Header information
headers = {"content-type" : "application/json"}

#Combine URL, API call and parameters variables
response = requests.post(url, data=json.dumps(payload), headers=headers).json()

# Return authentication token from respond body
return response["response"]["serviceTicket"]

def main():

#Assign obtained authentication token to a variable. Provide APIC-EM's URL address
auth_token = get_token(apic_em_ip)
print("\n")		
print("Service Ticket:", auth_token)

if name == "main":
main()


How can i install the REQUEST module to bluemix in order to run that python script

You cannot easily do that. The application is a node.js app and the buildpack that creates it only knows how to do things with node. There is no mechanism for installing extra python modules.

But you really should be doing such a straightforward http request using the HTTP Request node in a flow.

I'm doing all these alternate approach is because of SSL handshake error arised in HTTP Request node

Hello Nick, we tried the same by deploying node-red from our local environment rather using cloud environment and the script was executed successfully without the Request module being installed.