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

[Wordpress] Default Wordpress bitnami instance on AWS Lightsail returns 401 error while using REST API to create a post #1243

Closed
a-v-ershov opened this issue Nov 22, 2023 · 4 comments
Assignees
Labels
solved tech-issues The user has a technical issue about an application wordpress

Comments

@a-v-ershov
Copy link

Platform

AWS

bndiagnostic ID know more about bndiagnostic ID

3ed4abdd-09bf-fad7-d154-3ea89f94b70d

bndiagnostic output

[Resources]

Your instance has little available RAM memory.

 total used free shared buff/cache available Mem: 453 329 5 43 118 67 Swap: 634 
170 464

You could try to increase your instance's memory. Please check your cloud
provider's documentation for more information.
Press [Enter] to continue:

[Connectivity]

Server ports 22, 80 and/or 443 are not publicly accessible. Please check the
following guide to open server ports for remote access:

https://docs.bitnami.com/general/faq/administration/use-firewall/

[Apache]

Found recent error or warning messages in the Apache error log.
[Sensitive]

bndiagnostic was not useful. Could you please tell us why?

I didn't find errors related to rest api

Describe your issue as much as you can

I created a WordPress instance using AWS Lightsail. I added SSL certificate and redirects from non-www to www and from http to https. Then, I created credentials for api usage.
I checked that GET request to get posts works (/wp/v2/posts)
But POST request to create a post (using the same endpoint) returns 401 error.

Status code: 401.
Response: {"code":"rest_cannot_create","message":"Sorry, you are not allowed to create posts as this user.","data":{"status":401}}

@a-v-ershov a-v-ershov added the tech-issues The user has a technical issue about an application label Nov 22, 2023
@github-actions github-actions bot added the triage Triage is needed label Nov 22, 2023
@jotamartos
Copy link
Collaborator

Hi @ershovio,

Thank you for using Bitnami. That's a specific question about the application and how it works. Please take a look at the app's documentation and forums to get more information about it.

Thanks

@a-v-ershov
Copy link
Author

Hi @ershovio,

Thank you for using Bitnami. That's a specific question about the application and how it works. Please take a look at the app's documentation and forums to get more information about it.

Thanks

Hi!
As I said I tried the default Bitnami instance of Wordpress. The REST API should work as described here: https://developer.wordpress.org/rest-api/

But authentication doesn't work somehow. So, I suppose it's related to some Bitnami's changes in the Wordpress instance. It's the reason I created a ticket here.

@jotamartos jotamartos removed the triage Triage is needed label Nov 24, 2023
@jotamartos
Copy link
Collaborator

jotamartos commented Nov 24, 2023

You need to use https and an "Application Password" to perform those requests.

https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#basic-authentication-with-application-passwords

I just created a post using the UI and deleted it later using this command

# curl -k -X DELETE --user "user:1ONS pulJ 0AQO 578p pxdu nTiy" https://localhost/wp-json/wp/v2/posts/6
{"id":6,"date":"2023-11-24T12:02:44","date_gmt":"2023-11-24T12:02:44","guid":{"rendered":"http:\/\/localhost\/?p=6","raw":"http:\/\/localhost\/?p=6"},"modified":"2023-11-24T12:20:09","modified_gmt":"2023-11-24T12:20:09","password":"","slug":"test__trashed","status":"trash"
...

Please take a look at the documentation to get more information about how to use the API

@a-v-ershov
Copy link
Author

Sorry, I used an incorrect user 🙏. I'll close the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved tech-issues The user has a technical issue about an application wordpress
Projects
None yet
Development

No branches or pull requests

2 participants