Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on lemmy.world
support·Lemmy.world Supportbyaa45cc00

How do you edit an existing post via the API?

Documentation is lacking and the API does not return error messages consistently.
https://join-lemmy.org/api/interfaces/EditPost.html
is unhelpful since I'm looking for the URL to hit.
I assumed I'd be able to use

https://lemmy.world/api/v3/post/edit?id=xxxxxx&body=YYYYYEEEAAAHHHHHH  

but it does not work and none of my other guesses about the address have worked either. I don't believe it's an authorization problem.

View original on lemmy.world
2

9 replies

aa45cc00reply
lemmy.world

I should have been more clear - I meant how do you edit an existing post.

1
marsara9reply
lemmy.world

According to the code above if you send a PUT request to /api/v3/post?post_id=585124&auth=... it should edit this post you have here.

Just specify the new name, url, body, etc... per the EditPost struct.

1
aa45cc00reply
lemmy.world

Wait - never mind. It's just creating new posts and not editing the existing one...

1
marsara9reply
lemmy.world

make sure you're sending a PUT request and not a POST request. a PUT will edit, where-as a POST will create.

1

That's almost certainly what's going wrong. I'm working off of a very basic Python interface for the API that I found. Now I need to figure out how to send PUTs with Python's requests library....

1
aa45cc00reply
lemmy.world

Thank you! I got it. I thought all it needed was the id and the body, but you have to supply the name and the community_id as well.

1
marsara9reply
lemmy.world

Looking at the contract / struct. It looks like you should only need the post_id and the auth token. I don't even see a community_id parameter.

1

Okay, that did it - just like you said: use a requests.put with those parameters and that's all it needs. Thanks!

1

You reached the end

How do you edit an existing post via the API? | Spyke