Reputation: 531
We would like to get label for the field.
As per previous question: How do I get a field label by the field name?
But I need to get this through the REST API of Drupal.
Could anyone please suggest what should be the approach to use the Field API from as REST
Upvotes: 1
Views: 77
Reputation: 95
I can get values through the REST API.
/**
* Implements hook_menu().
*/
function sample_menu() {
$items['api/sample'] = array(
'title' => 'Sample REST API',
'page callback' => 'sample_api',
'access callback' => true
)
}
/**
* callback function for /api/sample
*/
function sample_api() {
$entityBody = file_get_contents('php://input'); // if you want to get post data
drupal_add_http_header('Content-Type', 'application/json');
// set values from Fields and so on
drupal_json_output(array("output" => 'this is rest api sample module output.', 'id' => 12345));
drupal_exit();
}
Upvotes: 1