Skip to content

Posts API

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

GET author/<str:author_id>/posts/

This will return all posts written by a given author.

Request Header

Basic authorization (base64 encoded username:password):
--header "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="

or token authorization is required:
--header "Authorization: Token 9d9ed917fe1ead2d1e27ac7dc233348ed2e3d4c0"

Request Requirements

No body required

Sample Response

[
  {
    "type": "post",
    "title": "This is the best post of all time",
    "id": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47/posts/ef2347c8cb4a47879c95442f0ee2a514",
    "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",
        " this",
        " with",
        " tags"
    ],
    "count": 0,
    "size": 50,
    "comments": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47/posts/ef2347c8cb4a47879c95442f0ee2a514/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"
    }
  },
  {
    "type": "post",
    "title": "This is the second best post of all time",
    "id": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47/posts/ad123c8cb4a47879c95442f0ee2a514",
    "source": "https://team6-project-socialdistrib.herokuapp.com/",
    "origin": "https://team6-project-socialdistrib.herokuapp.com/",
    "description": "this post that contains a little bit of text in it",
    "contentType": "text/plain",
    "content": "This is some text that goes in the post body",
    "categories": [
        "Other",
        "post",
        "with",
        "tags"
    ],
    "count": 0,
    "size": 50,
    "comments": "https://team6-project-socialdistrib.herokuapp.com/author/a3b412cdef384862ad5fb8a5366e0e47/posts/ad123c8cb4a47879c95442f0ee2a514/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

  • 200 OK upon a successful retrieval of a posts list
  • 400 BAD REQUEST if bad information is passed in the request
  • 403 FORBIDDEN if a user is not authenticated

Clone this wiki locally