POST | /posts |
---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreatePostResponse:
id: int = 0
slug: Optional[str] = None
response_status: Optional[ResponseStatus] = None
class PostType(str, Enum):
ANNOUNCEMENT = 'Announcement'
POST = 'Post'
SHOWCASE = 'Showcase'
QUESTION = 'Question'
REQUEST = 'Request'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreatePost(IPost):
organization_id: int = 0
type: Optional[PostType] = None
category_id: int = 0
title: Optional[str] = None
url: Optional[str] = None
image_url: Optional[str] = None
content: Optional[str] = None
lock: Optional[bool] = None
technology_ids: Optional[List[int]] = None
labels: Optional[List[str]] = None
from_date: Optional[datetime.datetime] = None
to_date: Optional[datetime.datetime] = None
meta_type: Optional[str] = None
meta: Optional[str] = None
ref_id: Optional[int] = None
ref_source: Optional[str] = None
ref_urn: Optional[str] = None
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /posts HTTP/1.1
Host: techstacks.io
Accept: application/json
Content-Type: application/json
Content-Length: length
{"organizationId":0,"type":"Announcement","categoryId":0,"title":"String","url":"String","imageUrl":"String","content":"String","lock":false,"technologyIds":[0],"labels":["String"],"fromDate":"0001-01-01T00:00:00.0000000","toDate":"0001-01-01T00:00:00.0000000","metaType":"String","meta":"String","refId":0,"refSource":"String","refUrn":"String"}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"id":0,"slug":"String","responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}