2

I'm trying to create a new node through REST on Drupal 8 with no success and a 403 (Forbidden) error. I'm using REST UI module to enable permissions with the following config for Content resources:

GET authentication: basic_auth formats: hal_json, json

POST authentication: basic_auth formats: hal_json, json

After many failed tries I installed a fresh copy of Drupal 8.2.3 to discard it had to be with the recent core upgrade on my original site. The big surprise is on the fresh site there are no other RESTful module permissions than Administer REST resource configuration, no permissions to grant DELETE, GET, PATCH or POST to each role.

I'm using Postman for testing purposes as follows:

Postman header screenshot

Request body:

{
    "_links": {
        "type": {
            "href": "http://fischer.dev:81/rest/type/node/article"
        }
    },
    "title": [
        {
            "value":"My article"
        }
    ],
    "type": [
        {
            "target_id":"article"
        }
    ]
}

User role is granted permissions to create Article nodes. I tried even with the admin credentials with no success. The GET method for retrieving an existing node is woking fine.

I don't know if there was any change on the latest Drupal release since the official documentation page for this module appears to be outdated. Am I missing something?

1 Answer 1

0

For headers you only need Content-Type and Authorization.

Your POST url needs to be http://fischer.dev:80/entity/node (this is only for POST).

If you are going to PATCH or DELETE, the url would then be the url of the node, Ex: http://fischer.dev:80/node/1 that you want to update (patch) or delete.

enter image description here

PS: Not really sure why you have port numbers in your url, and why you were using port 81 instead of 80, using http://fischer.dev/entity/node should be good enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.