Overview#
I had an opportunity to add content to Drupal using Python, so this is a memo of the process. I referenced the following article.
https://weimingchenzero.medium.com/use-python-to-call-drupal-9-core-restful-api-to-create-new-content-9f3fa8628ab4
Preparing Drupal#
I set it up on Amazon Lightsail. The following article is a useful reference.
https://annai.co.jp/article/use-aws-lightsail
Modules#
Install the following modules.
- HTTP Basic Auth
- JSON:API
- RESTful Web Services
- Serialization
Changing JSON:API Settings#
Access the following page to change the settings.
</admin/config/services/jsonapi>

Python#
Set {IP address or domain name} and {password} as appropriate.
For Amazon Lightsail, the default username is user. You can check the password with the following command.
Additional Notes#
I also attempted to register a node_type as follows.
As a result, I received a Method Not Allowed error as shown below.
I plan to continue investigating this issue.
Summary#
I will continue investigating in order to use Drupal as a headless CMS.