Skip to content

Instantly share code, notes, and snippets.

@fhightower
Created August 14, 2019 12:20
Show Gist options
  • Save fhightower/e617b70a8854e4d53c7768c0ef8c78a7 to your computer and use it in GitHub Desktop.
Save fhightower/e617b70a8854e4d53c7768c0ef8c78a7 to your computer and use it in GitHub Desktop.
Making requests to tiddlywiki
"""Code showing how to create a tiddler in tiddly wiki using python. I was not able to get this working without the "X-Requested-With" header."""
import requests
TIDDLY_WIKI_URL = 'https://localhost:8080'
TIDDLY_WIKI_REQUEST_HEADERS = {
# this "X-Requested-With" header is the key to making these requests work
'X-Requested-With': 'TiddlyWiki',
'Content-Type': 'application/json'
}
tiddler_data = {
'title': 'foo',
'text': 'bar'
}
url_path = f'{TIDDLY_WIKI_URL}/recipes/default/tiddlers/{tiddler_title}'
response = requests.put(url, data=tiddler_data, headers=TIDDLY_WIKI_REQUEST_HEADERS)
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment