Created
February 17, 2022 02:49
-
-
Save andrewdoss-bit/ce47eb7983d94d895c70c222f911176b to your computer and use it in GitHub Desktop.
Upload json with only requests
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 | |
import io | |
import json | |
data = {"a": 1, "b": "world"} | |
buffer = io.StringIO() | |
json.dump(data, buffer) | |
buffer.seek(0) | |
url = 'https://import.bit.io/doss/json_upload/example' | |
headers = { | |
"Content-Disposition": "attachment;filename='data.json'", | |
"Authorization": "Bearer <API_KEY>" | |
} | |
response = requests.request("POST", url, headers=headers, data=buffer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment