You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to submit a post request to my resource containing a node reference to another node in my drupal site.
My resource is a log file where I can submit entries with a type and a description, and this has a node reference field which should be referencing a student.
I can use the restful drupal module to post a description and type (these are just text fields) and the node reference field is set to autocomplete, therefore I am trying to pass a node id and it should autocomplete the rest of the reference.
Below is a code snippet of my resource:
<?php
/**
* @file
* Contains \Drupal\restful\Plugin\resource\GustLog__1_0.
*/
namespace Drupal\restful\Plugin\resource;
/**
* Class Gust Log
* @package Drupal\restful\Plugin\resource
*
* @Resource(
* name = "gustlog:1.0",
* resource = "gustlog",
* label = "Gust Log",
* description = "Export the Gust Log entity.",
* authenticationTypes = TRUE,
* authenticationOptional = FALSE,
* dataProvider = {
* "entityType": "gust_log",
* "bundles": {
* "gust_log"
* },
* },
* majorVersion = 1,
* minorVersion = 0
* )
*/
class GustLog__1_0 extends ResourceEntity implements ResourceInterface {
/**
* {@inheritdoc}
*/
protected function publicFields()
{
$public_fields = parent::publicFields();
// The mail will be shown only to the own user or privileged users.
$public_fields['type'] = array(
'property' => 'field_type',
);
$public_fields['description'] = array(
'property' => 'field_task_description',
);
$public_fields['nodeReference'] = array(
'property' => 'field_node_references'
);
return $public_fields;
}
}
Below is a screenshot of my postman requests. I have tried several different formats for the value of node reference, but it never creates the reference, only a blank array.
P.S. This is a project for a client who already had an installation of drupal and wanted a mobile app to interact with the site, I have very little experience with drupal prior to this and no experience with the RESTful module, so any help will be greatly appreciated. Thanks in advance.
The text was updated successfully, but these errors were encountered:
@charlie-rushton I am not available for support requests or other maintenance tasks on this module. I am focusing my volunteer time elsewhere nowadays.
Hi,
I am trying to submit a post request to my resource containing a node reference to another node in my drupal site.
My resource is a log file where I can submit entries with a type and a description, and this has a node reference field which should be referencing a student.
I can use the restful drupal module to post a description and type (these are just text fields) and the node reference field is set to autocomplete, therefore I am trying to pass a node id and it should autocomplete the rest of the reference.
Below is a code snippet of my resource:
Below is a screenshot of my postman requests. I have tried several different formats for the value of node reference, but it never creates the reference, only a blank array.
P.S. This is a project for a client who already had an installation of drupal and wanted a mobile app to interact with the site, I have very little experience with drupal prior to this and no experience with the RESTful module, so any help will be greatly appreciated. Thanks in advance.
The text was updated successfully, but these errors were encountered: