Post create

This commit is contained in:
simonwt 2026-03-31 11:03:31 +01:00
parent e775b3f456
commit 499c5aee98
3 changed files with 29 additions and 3 deletions

View file

@ -1,3 +1,4 @@
from .get import get
from .listbybranch import listbybranch
from .listbyuserprofile import listbyuserprofile
from .create import create

13
jobs/post/create.py Normal file
View file

@ -0,0 +1,13 @@
def create(API, payload: dict) -> dict:
"""
Creates a new post in the API.
Args:
payload (dict): The data for the new post.
Returns:
dict: The post data.
"""
print(f"Creating a new post with payload: {payload}")
post_data = API.make_request("POST", "content", "post", data=payload, authenticate=True)
return post_data

View file

@ -42,6 +42,18 @@ if not API.is_token_valid():
# print("-----------------------------")
# feed = API.run_job('post.listbybranch', "music")
# print(feed)
# print("-----------------------------")
# feed = API.run_job('post.listbyuserprofile', "simon-little")
# print(feed)
print("-----------------------------")
feed = API.run_job('post.listbyuserprofile', "simon-little")
print(feed)
post = API.run_job('post.create', {
"blurLabel": None,
"cardUrl": None,
"postText": "This is a test post created via the API wrapper.",
"collaborative": False,
"parent": {
"pk": "maintrunk#maintrunk",
"sk": "maintrunk#maintrunk"
}
})
print(post)