Skip to content

Articles

Mateusz Donhefner edited this page Jan 18, 2021 · 5 revisions

Articles

Endpoint for handling articles.

Table of Contents

Articles

List of articles

Permission : Anonymous users are allowed.

Command Method Route Description
List GET /{culture}/api/Articles Fetches lists of articles with selected pagination filter.

Call to this API method will retrive a list of articles. Response is paginated:

  • its default page size is 10 and cannot be higher than 25
  • default page number is 1 and cannot be lower than 1 These can be changed in request.

User can parametrize request:

  • PageNumber (default: 1) - will returns chosen page number, i.e. en-US/api/Articles?PageNumber=2
  • PageSize (default: 10) - will set size of page of response, i.e. en-US/api/Articles?PageSize=4

Response data will be in the following format:

{
  "data": [
    {
      "id": <guid>,
      "title": <string>,
      "image": <string>,
      "abstract": <string>",
      "content": <string>,
      "createdBy": <string>,
      "created": "2021-01-11T09:48:15.533Z"
    }
  ],
  "succeeded": <bool>,
  "errors": [
    <string>
  ],
  "message": <string>,
  "pageNumber": <int>,
  "pageSize": <int>,
  "firstPage": <string>,
  "lastPage": <string>,
  "totalPages": <int>,
  "totalRecords": <int>,
  "nextPage": <string>,
  "previousPage": <string>
}

Example response for en-US/api/Articles?PageNumber=1&PageSize=2:

{
  "pageNumber": 1,
  "pageSize": 2,
  "firstPage": "https://localhost:44324/en-US/api/Articles?pageNumber=1&pageSize=2",
  "lastPage": "https://localhost:44324/en-US/api/Articles?pageNumber=2&pageSize=2",
  "totalPages": 2,
  "totalRecords": 3,
  "nextPage": "https://localhost:44324/en-US/api/Articles?pageNumber=2&pageSize=2",
  "previousPage": null,
  "data": [
    {
      "id": "4057c24c-8afb-4f3f-9de9-c15b1d37fd3e",
      "title": "Second Article",
      "image": null,
      "abstract": "Nulla ullamcorper justo ex, vel ultricies augue tincidunt porta. Phasellus eros lorem, vehicula tincidunt tempor consectetur, eleifend molestie urna.",
      "content": "Duis tempus dolor nec ante ullamcorper consequat. Pellentesque sagittis mauris condimentum sollicitudin aliquet. Fusce tortor lorem, dignissim ac scelerisque at, blandit viverra leo. ",
      "createdBy": "",
      "created": "2020-12-17T09:11:46.262257"
    },
    {
      "id": "435d9b5b-17d7-437a-9b02-a18f711ec775",
      "title": "First Article",
      "image": null,
      "abstract": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eros quam, scelerisque eu odio a, maximus gravida sapien. Proin velit sapien, placerat nec lorem sit amet, tempor egestas velit.",
      "content": "In hac habitasse platea dictumst. Nulla efficitur justo eu nisi commodo blandit. Integer tempus sit amet urna a lobortis. Praesent lacus ipsum, accumsan vitae lectus eget, sodales dapibus diam.",
      "createdBy": "",
      "created": "2020-12-17T09:11:46.2615"
    }
  ],
  "succeeded": true,
  "errors": null,
  "message": null
}

Details of article

Permission : Anonymous users are allowed.

Command Method Route Description
Details GET /{culture}/api/Articles/{id} Fetches a single article by id.

Call to this API method will retrive a single article with selected id. Response data will be in the following format:

{
  "id": <guid>,
  "title": <string>,
  "image": <string>,
  "abstract": <string>",
  "content": <string>,
  "createdBy": <string>,
  "created": "2021-01-11T09:48:15.533Z"
}

Example response for en-US/api/Articles/3fa85f64-5717-4562-b3fc-2c963f66afa6:

{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "title": "Second Article",
  "image": null,
  "abstract": "Nulla ullamcorper justo ex, vel ultricies augue tincidunt porta. Phasellus eros lorem, vehicula tincidunt tempor consectetur, eleifend molestie urna.",
  "content": "Duis tempus dolor nec ante ullamcorper consequat. Pellentesque sagittis mauris condimentum sollicitudin aliquet. Fusce tortor lorem, dignissim ac scelerisque at, blandit viverra leo. ",
  "createdBy": "",
  "created": "2020-12-17T09:11:46.262257"
}

Create article

Permission : Only logged users with administrator or moderator role are allowed.

Command Method Route Description
Create POST /{culture}/api/Articles Adds a new article.

Call to this API method will result in the creation of a new article according to the arguments passed in the request body. The format of the arguments in the request body is JSON.

Request body will be in the following format:

{
  "id": <guid>,
  "title": <string>,
  "image": <string>,
  "abstract": <string>",
  "content": <string>
}

The response to this call will return id of newly created article:

{
  <guid>
}

Edit article

Permission : Only logged users with administrator or moderator role are allowed.

Update Method Route Description
Details PUT /{culture}/api/Articles/{id} Updates an existing article selected by id.

Call to this API method will result in the updating an article with selected id. Arguments are passed in the request body. The format of the arguments in the request body is JSON.

Request body will be in the following format:

{
  "id": <guid>,
  "title": <string>,
  "image": <string>,
  "abstract": <string>",
  "content": <string>
}

The response to this call will return status code 204 if article was edited correctly.

Delete article

Permission : Only logged users with administrator or moderator role are allowed.

Command Method Route Description
Delete DELETE /{culture}/api/Articles/{id} Deletes an article with selected id.

Call to this API method will result in deleting an article with selected id. The response to this call will return status code 204 if article was deleted correctly.

Clone this wiki locally