Skip to content

Instantly share code, notes, and snippets.

@cleg
Created June 3, 2013 12:01
Show Gist options
  • Save cleg/5697685 to your computer and use it in GitHub Desktop.
Save cleg/5697685 to your computer and use it in GitHub Desktop.
Simple example on how to update multiline text field
_NIMBLE_GATEWAY = "https://api.nimble.com"
_ACCESS_TOKEN = "HERE IS TOKEN"
def nimble_request(api_path, method='GET', access_token=None, body=None, headers=None, **kwargs):
args = {"access_token": _ACCESS_TOKEN}
if kwargs:
args.update(kwargs)
if isinstance(body, dict): # we got JSON here, put it into body and set correct content-type
headers['content-type'] = 'application/json'
body = dumps(body)
url = '%s%s?%s' % (_NIMBLE_GATEWAY, api_path, urlencode(args))
request = tornado.httpclient.HTTPRequest(url, method=method, body=body, headers=headers)
http = tornado.httpclient.AsyncHTTPClient()
http.fetch(request, on_result)
def make_request():
sample_data = {
"fields": {
"Bio": [{
'modifier': "",
"value": "New\nbio123",
}]
}
}
# contact ID in URL, PUT method to update contact
self.nimble_request('/api/v1/contact/5175af1bb8e4a156a72dfe94', body=sample_data, method="PUT")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment