Skip to content

Instantly share code, notes, and snippets.

@epugh
Created May 12, 2024 17:43
Show Gist options
  • Save epugh/258f66c3672b62ccf14357b915e8fd01 to your computer and use it in GitHub Desktop.
Save epugh/258f66c3672b62ccf14357b915e8fd01 to your computer and use it in GitHub Desktop.
Sample of uploading a book.json file to Quepid through API with token
import requests
import json
def post_book_data(quepid_uri, headers, data):
url = f'{quepid_uri}/api/import/books.json'
headers['Authorization'] = f'Bearer 019d3bc549ca751940288972375eb8c1778bcc555eda84865d680632381a72af'
response = requests.post(url, headers=headers, data=data)
return response.text
# Example usage
quepid_uri = 'http://localhost:3000' # Replace with your quepid URI
headers = {'Content-Type': 'application/json'}
# Read book data from file
with open('book.json', 'r') as file:
data = file.read()
print(data)
response_data = post_book_data(quepid_uri, headers, data)
print(response_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment