Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
I tried to use the module using api call.
I tried to get node by its nid:
try {
$api = services_client_connection_get('resources');
$node = $api->get('node', 1);
//var_dump($api->getDebug());
var_dump($node);
}
catch (ServicesClientConnectionResponseException $e) {
$e->log();
}
but it always return NULL
using debug method I looked into retuned object and the field data was set to NULL value, but the raw_response was filled properly,
is this kind of bug, or am I missing something, which needs to be done? Setting response to JSON and updating your code to this prototype:
public function get($resource, $id = NULL, $data = array()) {
$this->http_request = $this->createRequest(array(
'resource' => $resource,
'id' => $id,
'data' => $data,
'action' => 'retrieve'
));
$processed_request = $this->processRequest();
if (!$processed_request->data) {
$processed_request->data = json_decode($processed_request->raw_response);
}
return $processed_request->data;
}
helped me to load the data, but this is probably not the best solution. Should the data field always have any value?
Comments
Comment #1
peter.milan CreditAttribution: peter.milan commentedProblem was in configuration of Server part (admin/structure/services_client/connection/list/resources/server)
There was set bad format. After updating the format everything works perfect.