Endpoint for creating Pages

I wrote an Obsidian plugin named Micro.publish which I use to publish extended posts on my blog. This plugin is open source, and you can find its code on GitHub.

However, not everything I publish to Micro.blog is the in format of blog posts. I also publish content in pages, as some sort of Digital Garden. Given its small scale, I’ve called it “Kleingarten”.

Upon reviewing the API documentation, I couldn’t find the endpoint for creating and updating pages.

Could you direct me to the documentation? Furthermore, it appears that neither the Micro.blog app for macOS nor the one for iOS supports page creation. However, as MarsEdit has this capability, I presume there’s a dedicated endpoint for this purpose.

1 Like

Here’s the documentation for microblog.newPage and microblog.editPage.

And here’s documentation for the Micropub way.

1 Like

Thanks for the links! I wouldn’t have thought to check there and editing pages was something I was considering adding :smile:

1 Like

This is great material, thank you @sod. I’ll implement this using the Micropub method. I’ve tested it here, and to update a page, I don’t need to make any modifications to my code. I simply need to adjust the code to create the page. The only detail missing from the Micropub documentation is whether (or how) to include the page in the blog navigation. I’ll try to figure that out. Thanks again.

There’s no way with Micropub to set whether a new page appears in the navigation of your blog. It always defaults to including it. This is possible in the XML-RPC interface, though, with the is_navigation param.

We should add an option via Micropub. In the meantime, if you don’t mind working with XML, you can switch between both APIs. The authentication token used in Micropub also works as the “password” in XML-RPC.

1 Like

Thank you for the detailed information on the Micropub and XML-RPC interfaces. After considering the options, I have decided to stick with the Micropub REST API for now.

To address the issue of new pages defaulting to the navigation bar, I’ll advise users to visit Micro.blog and manually remove the page from the navigation if they so desire.

Furthermore, I’ll try to maintain consistency within the plugin. Mixing two different approaches could potentially introduce technical debt, especially given that this is a side project.

I’ve rolled out the feature to all users today.

https://otavio.cc/2023/10/31/micropublish.html

Thanks @manton!

This looks great! I’m going to add an optional parameter (mp-navigation = true/false) so you have more control over this from Micropub. I’ll roll it out later this week.

This change is now live.

1 Like

That is amazing! Thank you so much Manton for looking into this! :bowing_man: :bowing_man: :bowing_man:

I’ve published Micro.publish 2.2.0, with the change. Blog post:

https://otavio.cc/2023/11/01/micropublish.html

Pull Request with the changes:

Thank you again, Manton, for taking your time and working on it from your side!

Cool, congrats on the update!

1 Like

Hi @manton,

I’m converting my Obsidian plugin to use JSON payloads and it looks like the mp-navigation isn’t working.

I’ve tried adding it to the property group, and directly to the root, but didn’t work. Also tried to send it as array (as other properties in the Micropub payload), but didn’t work either.

{
  "type": [
    "h-entry"
  ],
  "mp-destination": "https://otaviocc-test.micro.blog/",
  "properties": {
    "name": [
      "Page 5"
    ],
    "content": [
      "Another test"
    ],
    "mp-channel": [
      "pages"
    ],
    "mp-navigation": "true" // and [ "true" ] < ---- HERE
  }
}

and

{
  "type": "h-entry",
  "mp-destination": "https://otaviocc-test.micro.blog/",
  "mp-navigation": "true",  // and [ "true" ] < ---- HERE
  "properties": {
    "name": [
      "Fourth Page"
    ],
    "content": [
      "Another attempt"
    ],
    "mp-channel": [
      "pages"
    ]
  }
}

Is this a known issue?

Another topic, the book has the following example in this chapter:

POST /micropub
Authorization: Bearer 123456789
Content-Type: application/json

{
  "type": "h-entry",
  "properties" {
    "content": "Hello",
    "mp-channel": "pages"
  }
}

but I believe they should be arrays of strings. If I’m not mistaken, when I tried "mp-channel": "pages" it didn’t work. I believe I had to send "mp-channel": ["pages"] instead.

Thanks!

Thanks @otaviocc! I posted a question about channels on this GitHub Micropub issue.

To clarify Micro.blog’s current implementation:

  • mp-navigation goes at the root level of the JSON, outside of properties.
  • mp-channel should be an array inside properties, you’re right, but personally I think it probably doesn’t belong there since it seems inconsistent with mp-destination, etc.

Micro.blog tries to be flexible about property values to accept arrays or simple strings, but it doesn’t in the case of mp-channel. Definitely best to stick to arrays to match the Micropub spec.

Thanks @manton. This is the result from my investigation, and no matter where I place the mp-navigation, it never gets set.

Ah, you’re right. Digging into this I see that mp-navigation wasn’t working for the JSON version of these requests. I’ll fix that today!

Awesome! Thank you so much for looking into this, @manton :+1:

Okay, I think all these changes are ready now. It supports a couple different variations now, but I recommend this:

{
  "type": "h-entry",
  "mp-channel": "pages",
  "mp-navigation": true,
  "properties": {
     ...
   }
}
1 Like

Thank you @manton! I’ll update my code later today and release an updated version of my Obsidian plugin. I’ll post here the results.

All good @manton! Update my plugin and released a new version. Thank you so much for the changes.

Great! Thanks for finding these problems. The official iOS and macOS apps don’t use the JSON flavor of Micropub, so I didn’t catch these earlier.