$_POST returns empty value in custom service
Solutions
You are passing every element as individual element, so you can't get these values in $_POST array. I have executed your code at my end and retrieve each element value by following call back function.
function _send_mail_service_create($nid, $recipient, $sender, $subject, $body) {
echo "nid => ".$nid;
echo "\nrecipient => ".$recipient;
echo "\nsender => ".$sender;
echo "\nsubject => ".$subject;
echo "\nbody => ".$body;
}
Output:
nid => 1834
recipient => [email protected]
sender => [email protected]
subject => xyz
body => a
If you want to have these values in an array then you can use this in following way:
/**
* 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',
'callback' => '_send_mail_service_create',
'access callback' => 'user_access',
'access arguments' => array('access content'),
'access arguments append' => FALSE,
'args' => array(
array(
'name' => 'title',
'optional' => FALSE,
'source' => 'data',
'type' => 'string',
'description' => 'The data collected through JSON',
),
),
),
),
),
);
return $api;
}
function _send_mail_service_create($arg) {
print_r($arg);
}
Output:
Array
(
[nid] => 1834
[recipient] => [email protected]
[sender] => [email protected]
[subject] => xyz
[body] => a
)