Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: getting one blog does not accept ?body=html, but getting all blogs does #829

Open
MeowcaTheoRange opened this issue Nov 26, 2023 · 1 comment

Comments

@MeowcaTheoRange
Copy link

Describe the bug

When using the WriteFreely API to get all of a blog's posts, you can pass the parameter ?body=html to get HTML-formatted blog bodies.
/api/collections/test/posts?body=html

{
  "code": 200,
  "data": {
    "alias": "test",
    "title": "Test Blog",
    "description": "Hello, world!",
    "style_sheet": "",
    "public": true,
    "format": "blog",
    "views": 0,
    "url": "https://example.com/test/",
    "verification_link": "",
    "total_posts": 1,
    "posts": [
      {
        "id": "34hr3jrjjt",
        "slug": "test",
        "appearance": "norm",
        "language": "en",
        "rtl": false,
        "created": "2023-08-23T00:00:00-05:00",
        "updated": "2023-10-11T21:06:45-05:00",
        "title": "Test",
        "body": "<h1>This is a test.</h1>\n<a href="https://example.com/">Hello, world!</a>",
        "tags": [],
        "paid": false,
        "views": 1
      }
    ],
    "Format": null
  }
}

However, when getting one of a blog's posts, this parameter is no longer accepted and the body becomes Markdown.
/api/collections/test/posts/test?body=html

{
  "code": 200,
  "data": {
    "id": "34hr3jrjjt",
    "slug": "test",
    "appearance": "norm",
    "language": "en",
    "rtl": false,
    "created": "2023-08-23T00:00:00-05:00",
    "updated": "2023-10-11T21:06:45-05:00",
    "title": "Test",
    "body": "# This is a test.\n[Hello, world!](https://example.com/)",
    "tags": [],
    "paid": false,
    "views": 1
  }
}

Expected behavior

The API should accept the ?body=html parameter on both routes, so blogs can be returned in HTML, regardless of the method.

Application configuration

  • Single mode or Multi-user mode?: Multiple users
  • Database?: mysql
  • Open registration?: Invite-only
  • Federation enabled?: yes

Version or last commit: WriteFreely v0.14.0 on Ubuntu 22.04.3 LTS x86_64

@MeowcaTheoRange MeowcaTheoRange changed the title /api/collections/.../posts/... does not accept ?body=html like /api/collections/.../posts does API: getting one blog does not accept ?body=html, but getting all blogs does Nov 26, 2023
@thebaer
Copy link
Member

thebaer commented Feb 2, 2024

This is definitely something we can support in the API -- thanks for reporting it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants