How to Retrieve a Post by ID Using Wordpress REST API?

I’m sorry to hear that you’re encountering an error. The error message suggests that the server is expecting an Authorization header that it’s not receiving. In the WordPress REST API, authentication is typically handled via Basic Auth, which requires an Authorization header. However, it seems like the auth option in the axios request might not be working as expected. Instead, you could try manually setting the Authorization header using Base64-encoded credentials. Here’s how you can modify your code: ```
import { axios } from “@pipedream/platform”; import { Buffer } from ‘buffer’; export default { props: { wordpressUrl: { type: “string”, label: “WordPress Site URL”, }, username: { type: “string”, label: “Username”, }, password: { type: “string”, label: “Password”, }, title: { type: “string”, label: “Post Title”, }, content: { type: “string”, label: “Post Content”, }, }, async run({ $ }) { const url = ${this.wordpressUrl}/wp-json/wp/v2/posts; const credentials = Buffer.from(${this.username}:${this.password}).toString(‘base64’); const data = { title: this.title, content: this.content, status: ‘publish’, }; const response = await axios($, { method: “POST”, url: url, headers: { ‘Authorization’: Basic ${credentials}, }, data: data, }); return response; }, };