尝试了POST访问restful api或者用js的库,都返回500错误。
代码片段如下:// 创建 Core API 客户端
const coreApiClient = createCoreApiClient(axiosInstance);
// 发布新博客文章
async function createBlogPost() {
try {
const response = await coreApiClient.content.post.createPost({
post: {
spec: {
title: "我的第一篇博客", // 文章标题
slug: "my-first-blog", // 自定义文章路径(可选)
releaseSnapshot: "content", // 发布快照类型
content: {
raw: "<p>这里是博客正文内容</p>", // 支持 HTML
rendered: "" // 留空会自动生成
},
publish: true // 是否立即发布
},
apiVersion: "content.halo.run/v1alpha1",
kind: "Post"
}
});
console.log("文章发布成功:", response.data);
} catch (error) {
console.error("发布失败:", error.response?.data || error.message);
}
}
报错如下:
发布失败: {
type: 'about:blank',
title: 'Internal Server Error',
status: 500,
detail: 'Something went wrong, please try again later.',
instance: 'http://192.168.0.109:8090/apis/content.halo.run/v1alpha1/posts',
requestId: '21469193-10887',
timestamp: '2025-03-11T03:08:54.131279043Z'
}
求帮忙