this post was submitted on 15 Oct 2025
3 points (100.0% liked)

PieFed API & mobile app dev

120 readers
1 users here now

Announcements and discussions about the PieFed API - changes, improvements and general co-ordination between the frontend developers and the core of PieFed.

founded 3 months ago
MODERATORS
 

I am created a piefed interface as a fun personal project but every time I try to create a post I get the following error:

{  
    "code": 400,  
    "message": "Validation failed",  
    "status": "{'json': {'title': ['Missing data for required field.'], 'community_id': ['Missing data for required field.']}}"  
}  

It says I'm missing the title and community but here's what the body looks like on my most recent attempt:

{  
        "body": "[Source](https://mstdn.social/@grickle/115345057031028219)\n\nAlt Text: A cartoon illustration of a vampire in his living room surrounded by his pesky West Highland terriers. Caption reads \"He and the Westies had tormented the village for centuries now.\"",  
        "community_id": 891,  
        "language_id": 0,  
        "nsfw": false,  
        "title": "Forever pests.",  
        "url": "https://media.mstdn.social/media_attachments/files/115/345/056/927/012/957/original/b20b96453c62665c.jpeg"  
}  

The title is very much there and so is the community ID. Am I missing something?

top 10 comments
sorted by: hot top controversial new old
[–] wjs018@piefed.wjs018.xyz 2 points 3 weeks ago (1 children)

For what its worth, I just copy/pasted your payload and was able to make a post just fine. I only changed the community_id.

[–] Maven@crust.piefed.social 1 points 3 weeks ago (1 children)
[–] wjs018@piefed.wjs018.xyz 3 points 3 weeks ago (1 children)

Alright, if I had to guess, the problem might be in how you are submitting your payload. The fact that those two fields are the only required ones and both of them are considered missing tells me that the most likely scenario is that piefed isn't receiving any of your payload.

The POST /post endpoint takes a request body with the json structure that you have there. Passing data to the api in a request body like this is different than passing data in query parameters in the url. I am not sure what tool/language you are using to interface with the api, but make sure you are passing the json in the right way for the endpoint.

[–] Maven@crust.piefed.social 1 points 3 weeks ago (1 children)

I'm using reqwest within Rust. I think youre definitely right though. Tomorrow when I'm back at my desk ill try submitting the body in a different way

[–] wjs018@piefed.wjs018.xyz 2 points 2 weeks ago (1 children)

I don't really know rust at all...but combining what I found from a quick search here and the official docs, it looks like you need to build a structure matching the json that is then serialized into json by reqwest rather than passing a json string directly.

[–] Maven@crust.piefed.social 3 points 2 weeks ago* (last edited 2 weeks ago)

omfg... there was a typo in my header...

it's working now

[–] wjs018@piefed.wjs018.xyz 1 points 3 weeks ago (1 children)

What instance are you trying to post to?

[–] Maven@crust.piefed.social 1 points 3 weeks ago

Crust.piefed.social on this account

[–] Maven@crust.piefed.social 1 points 3 weeks ago (1 children)

semi-related note... In the API the form is limited to just:

{  
  "title": "string",  
  "community_id": 0,  
  "body": "string",  
  "url": "string",  
  "nsfw": true,  
  "language_id": 0  
}  

But the piefed "create post" page allows you to add a few extra things like alt text. How would one add alt text through the api?

[–] wjs018@piefed.wjs018.xyz 2 points 3 weeks ago

Yeah, the api is comparatively limited compared to the web ui still in many ways. This is one of them.