3

I have installed RESTful Web Services on my Drupal 8 site, I activated the field_collection_item resource (/field_collection_item/{field_collection_item}) with all the methods available (GET, POST, etc with authentication:basic_auth, cookie and formats:hal_json, json).

I have a content-type with a field collection in it (name:field_field_collection). In order to create a new node of this content-type, I have to create the field collection item first but I can not succeed because I get 403 Forbidden even though I'm properly authenticating onto the system.

My request URL is : http://my_server.com/entity/field_collection_item?_format=hal_json (POST).

The header of the request is :

 POST /entity/field_collection_item?_format=hal_json HTTP/1.1
Host: my_server.com
X-CSRF-Token: P1Z8fnxb0-tTR3CLqNJMSDnU_DQDFnt2ko0Jnitwsd0
Authorization: Basic my_user:my_password
Content-Type: application/hal+json

The body of my request is :

{  
  "_links": {
      "type": { "href":"http://my_server.com/rest/type/field_collection_item/field_field_collection" }
  },
  "field_text1":[{"value": "1111"}],
  "field_text2":[{"value": "2222"}],
  "field_name":[{"target_id": "field_field_collection"}]  
   }
}

field_field_collection is the name of my field_collection entity. field_text1, field_text2 are the text fields of my collection.

When I make the request with POSTMAN or DHC I get 403 Forbidden response.

Can anyone point me in the right direction? What am I doing wrong? Is there another way that this request can be done?

1 Answer 1

1

Have you checked the endpoints permissions?

It sounds like you have setup the REST resource correct.. but you also have to set the permissions so anon users can access it.

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.