lunduke-cli/examples/draft_post.py

24 lines
570 B
Python
Raw Normal View History

2025-04-12 16:30:44 +00:00
from lunduke.client import DiscourseClient
def main():
client = DiscourseClient()
2025-04-12 22:56:34 +00:00
categories = client.get('/categories.json').json()['category_list']
print(categories)
2025-04-12 16:30:44 +00:00
try:
draft_data = {
2025-04-12 22:56:34 +00:00
"title": "Testing 1 2 3",
"raw": "This is only a test",
"category": 15
}
2025-04-12 16:30:44 +00:00
response = client.post('/posts.json', data=draft_data)
print(f"Draft created successfully: {response}")
except Exception as e:
print(f"Error creating draft: {e}")
if __name__ == "__main__":
main()