Created
January 15, 2014 19:57
-
-
Save dpawluk/8443329 to your computer and use it in GitHub Desktop.
Regular REST api example using python
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
import requests | |
payload = '{"ticket":{"requester":{"name":"Dan Pawluk", "email":"daniel.pawluk@me.com"}, "subject":"My printer is on fire!", "comment": { "body": "I want thousands of tickets" }}}' | |
s = requests.Session() | |
s.headers.update({'Content-Type': 'application/json'}) | |
s.auth = ('{username}','{password}') | |
#r = s.post("http://requestb.in/1hjs6jw1", data=payload) | |
for x in range (0,11999): | |
try: | |
r = s.post("https://sandedboxy.zendesk.com/api/v2/imports/tickets.json", data=payload) | |
print("finished with request number:" + str(x)) | |
except requests.exceptions.ConnectionError as e: | |
print("There was a connection error: %s" % (e)) | |
except requests.exceptions.Timeout as e: | |
print("There was a timeout!!!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment