created a custom service resource to catch some data from the user through post method. but while I am accessing the service ie http://dev.localhost:8082/rest/send_mail/retrive.json
Query: curl -X POST -H "Accept-Encoding: gzip" -H "Content-Type: application/json; charset=utf-8"
sending the data in POST is : { "nid" :"1834", "recipient" :"charubachi.rath@abc.com", "sender":"charubachi.rath@abc.com", "subject": "xyz", "body":"a" }
How to accept the data
in my .module file
<?php
/**
* Implementation of hook_services_resources().
*/
function send_mail_service_services_resources() {
$api = array(
'send_mail' => array(
'operations' => array(
'create' => array(
'help' => 'Drupal 7 Services 3 test',
'file' => array('file' => 'inc', 'module' => 'send_mail_service'),
'callback' => '_send_mail_service_create',
'access callback' => 'user_access',
'access arguments' => array('access content'),
'access arguments append' => FALSE,
'args' => array(
array(
'name' => 'nid',
'optional' => FALSE,
'source' => array('data' => 'nid'),
'type' => 'int',
'description' => 'The nid of the node to get',
),
array(
'name' => 'recipient',
'type' => 'string',
'description' => t('recipient'),
'source' => array('data' => 'recipient'),
'optional' => TRUE,
'default' => '0',
),
array(
'name' => 'sender',
'type' => 'string',
'description' => 'sender',
'source' => array('data' => 'sender'),
'optional' => TRUE,
'default' => '0',
),
array(
'name' => 'subject',
'type' => 'string',
'description' => 'subject',
'source' => array('data' => 'subject'),
'optional' => TRUE,
'default' => '0',
),
array(
'name' => 'body',
'type' => 'string',
'description' => 'body',
'source' => array('data' => 'body'),
'optional' => TRUE,
'default' => '0',
),
),
),
),
),
);
return $api;
}
in my call back function when I am trying to print $_POST I am getting empty values.
$data
in your services callback.