Skip to content

Create Article

  Method: POST

/api/ps/articles

  Headers

  • 'Content-Type': 'application/json'

  Parameters

  • title - title article, required
  • description - short description, required
  • content - content article, required
  • titleRu - title article, optional
  • descriptionRu - short description, optional
  • contentRu - content article, optional
  • category - ANDROID, WEB, IOS, OTHER, required
  • publicImage - url image, required
  • isPublished - is public on website, required
  • uploads - ids uploads for relations, required

Code samples

await fetch('/api/ps/articles', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        title: 'Title',
        description: 'Description',
        content: 'Content',
        titleRu: 'Title',
        descriptionRu: 'Description',
        contentRu: 'Content',
        category: 'OTHER',
        listImage: 'https://keygenqt.com/images/blog/601076d399c15.jpg',
        viewImage: 'https://keygenqt.com/images/blog/601076d399c15.jpg',
        isPublished: false,
        uploads: [1, 2, 3], // ids uploads for relations
    })
}).then(async (response) => {
    console.log(response)
})
  HTTP response status codes
Status code Description
200 OK
400 Bad Request
422 Form validate
500 Internal Error

  Status: 200

{
    "id": 1,
    "title": "Title",
    "description": "Description",
    "content": "Content",
    "titleRu": "Title",
    "descriptionRu": "Description",
    "contentRu": "Content",
    "category": "OTHER",
    "listImage": "https://keygenqt.com/images/blog/601076d399c15.jpg",
    "viewImage": "https://keygenqt.com/images/blog/601076d399c15.jpg",
    "isPublished": false,
    "uploads": [
        {
            "id": 1,
            "fileName": "d523f3fb-a8fe-49d9-9e67-3ce8b3231037.png",
            "fileMime": "image/png",
            "originalFileName": "screenshot-17.png",
            "createAt": 1661592987307
        }
    ]
}

  Status: 400

{
    "code": 400,
    "message": "Bad Request"
}

  Status: 422

{
    "code": 422,
    "message": "Error update article, please check the correctness of data entry",
    "validate": [
        {
            "filed": "content",
            "errors": [
                "Must not be null and not blank"
            ]
        },
        {
            "filed": "title",
            "errors": [
                "Size must be between 3 and 255",
                "Must not be null and not blank"
            ]
        }
    ]
}

  Status: 500

{
    "code": 500,
    "message": "Internal Error"
}