Skip to content

Create a new Post

Fraser Redford edited this page Apr 15, 2021 · 3 revisions

POST author/<str:author_id>/posts/

This will create a new post for a given author.

Request Requirements

Field Required/Optional Description
title Required The headline for the post
source Optional The host url that sent this post
origin Optional The host url that created the post
description Required A description of the post
contentType Required The format of content sent (text/markdown, text/plain, application/base64, image/png, image/jpeg)
content Required The information being posted
categories Required Comma separated tags to describe a post
visibility Required Sets who can view the post ("PUBLIC", "PRIVATE", "FRIENDS")
unlisted Required Sets if the post is listed in timelines
author Required Author object JSON to describe the post writer

Sample Request

{
    "type": "post",
    "title": "This is the third best post of all time",
    "description": "this is a text post",
    "contentType": "text/plain",
    "content": "This is some text that goes in the post body",
    "categories": [
        "Test",
        "post",
        "author"
    ],
    "visibility": "PUBLIC",
    "unlisted": false,
    "author": {
        "type": "author",
        "id": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47",
        "host": "https://team6-project-socialdistrib.herokuapp.com/",
        "displayName": "fraser",
        "url": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47",
        "github": "github.com/fredford"
    }
}

Sample Response

{
    "type": "post",
    "title": "This is the third best post of all time",
    "id": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47/posts/abcdefc8cb4a47879c95442f0ee2a514",
    "source": "https://team6-project-socialdistrib.herokuapp.com/",
    "origin": "https://team6-project-socialdistrib.herokuapp.com/",
    "description": "this is a text post",
    "contentType": "text/plain",
    "content": "This is some text that goes in the post body",
    "categories": [
        "Test",
        "post",
        "author"
    ],
    "count": 0,
    "size": 50,
    "comments": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47/posts/abcdefc8cb4a47879c95442f0ee2a514/comments",
    "commentList": [],
    "published": "2021-04-01T19:07:34.802718Z",
    "visibility": "PUBLIC",
    "unlisted": false,
    "author": {
        "type": "author",
        "id": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47",
        "host": "https://team6-project-socialdistrib.herokuapp.com/",
        "displayName": "fraser",
        "url": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47",
        "github": "github.com/fredford"
    }
}

Response Codes

  • 201 CREATED upon a successful creation of a post
  • 403 FORBIDDEN if a user is not authenticated
  • 400 BAD REQUEST if bad information is passed in the request

Clone this wiki locally