Created
June 20, 2016 10:47
-
-
Save clckwrkbdgr/06f30ffaa0e65d94035f465b27c995d7 to your computer and use it in GitHub Desktop.
Fieldbook API example using Python: read a dictionary of values from fieldbook sheet
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
POST_URL='https://api.fieldbook.com/v1/<USER_ID>/<SHEET_ID>' | |
KEY='...' | |
SECRET='...' | |
def get_fieldbook_json(): | |
try: | |
response = requests.get(POST_URL, auth=(KEY, SECRET)) | |
if response.status_code != 200: | |
return None | |
return response.json() | |
except requests.exceptions.ConnectionError as e: | |
print(e) | |
def parse_response(response_json): | |
result = {} | |
for record in response_json: | |
result[record['<FIRST_COLUMN_ID>']] = record['<SECOND_COLUMN_ID>'] | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment