Does anyone have experience with REST calls from Dynamo?


#1

I’m trying to create a collection of “generic” nodes to communicate with various REST (JSON) APIs. I have tried urllib2, which didn’t get my far. I would really like to use http://docs.python-requests.org/en/latest/user/install/#install Does anyone know if it is possible to use requests with dynamo?


#2

hmm, unfortunately it doesn’t look good:

what was the problem with urllib2?


#3

The problem with urllib2 is that it’s not as simple as requests. I am not yet so used to python, so maybe I just used urllib2 wrong.

Here is my code:
#The input to this node will be stored in the IN variable.
dataEnteringNode = IN
import sys
#append the path to the libs
sys.path.append(“C:\Program Files (x86)\IronPython 2.7\Lib”)
#import the libs
import urllib2
import json
import httplib

connection = httplib.HTTPSConnection(‘https://app.bimshark.com/api/v1/’)
connection.connect()
connection.request(‘POST’, ‘projects’, json.dups({
“template_type”: “”,
“title”: “Dynamo POST Test”,
“project_id”: “”,
“header”: “”,
“footer_left”: “”,
“footer_right”: “”
}), {
“X-Parse-bimshark-api-key”: “Insert key here”,
“Content-Type”: “application/json”
})
result = json.loads(connection.getrespones().read())

OUT = result