Skip to content

Instantly share code, notes, and snippets.

@MariuszWisniewski
Last active February 24, 2016 21:15
Show Gist options
  • Save MariuszWisniewski/f1b50b004cc512fe31d2 to your computer and use it in GitHub Desktop.
Save MariuszWisniewski/f1b50b004cc512fe31d2 to your computer and use it in GitHub Desktop.
import requests
import json
# I'll use direct API call, to show the logic of it - I don't want to cloud it with how certain libraries might work
# we check if the user_key was passed to the webhook
user_key = ARGS["POST"].get("user_key","")
if not user_key:
user_key = ARGS["GET"].get("user_key","")
# you this payload when testing inside a codebox
# {"POST": {"user_key":""}, "GET": {}}
api_key = ""
url = "https://api.syncano.io/v1/instances/{instance}/classes/test_class/objects/?api_key={api_key}".format(instance=META["instance"],api_key=api_key)
if user_key:
url = "{url}&user_key={user_key}".format(url=url,user_key=user_key)
r = requests.get(url)
response = HttpResponse(status_code=200, content=json.dumps(r.json()), content_type='text/json');
set_response(response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment