Created
June 3, 2013 12:01
-
-
Save cleg/5697685 to your computer and use it in GitHub Desktop.
Simple example on how to update multiline text field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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