22

Hope this will help you, For Drupal 7 Tools used: Firefox Poster add-on to do tests and debugging. There may be other add-on as well. But for this example im using Firefox add-on. To help editing and validating the JSON data you can use Edit the JSON data using this link Validate the JSON data using this link HTTP requests To make the HTTP requests, ...


22

There are 3 questions here: How to create a controller? How to create a service? How to use services in a controller? 1. Create a controller 1.1 Add a controller class - you did it. For others see Drupal documentation 1.2 Add a routing file - it looks like this is missing in your code: my_module.routing.yml my_module.my_route_name: path: '/my/path' ...


21

In a controller you inject services by using the service container. For example ModuleHandler: namespace Drupal\mymodule\Controller; use Drupal\Core\Controller\ControllerBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; class MyController extends ControllerBase { /** * The module ...


16

1. Reformulating the question Your example suggests that the data is read only on the Drupal side, with one-way syncing only. I think this is the most important factor to consider here, because in effect whatever solution you implement will be a variant of remote storage, syncing and local caching - even if the local caching ends up being entities in the ...


16

After many trials, I was able to resolve my issue Here is the JSON format to create user with role. { "name":"user343", "pass":"kes35@r4", "mail":"user343@sample.com", "status":"1", "roles":[ "4" ] } To assign multiple roles, { "name":"user344", "pass":"kes344@r4", "mail":"user344@sample.com", "status":"1", "roles":[...


14

pass your filter as follows: yourendpoint?args[0]=value&args[1]=value Good luck


12

Having multiple webservers behind a load balancer/reverse proxy is quite common for Drupal and well supported. Varnish is typically used in the Linux world because that thing is just insanely fast when being able to actually use it, meaning anonymous visitors. Which is obviously not the case for your site. Sessions are stored in the database by default, so ...


11

'Index' in services module will list out an entity(node, users, taxonomy..) in descending Order of its created time, vid, name etc based on the arguments that are passed. The common arguments for the Index are page - Page number of results to return (in pages of 20). fields - The fields you want returned. parameters - An array containing fields and ...


11

The module authenticates a web service call against drupal accounts. Enable the module Setup a drupal user Make the web service call with the credentials of the user. Note that with basic auth, the credential can be intercepted if SSL isn't used. The module uses the standard PHP authentication headers and submits the standard drupal login form, without ...


10

OH, just realized now, maybe I misunderstood the question 100% This is the code which basically generates the output: $serializer = \Drupal::service('serializer'): $output = $serializer->serialize($entity, $format); with $format for example being 'json'. Luckily the serializer is symetric, so you can do the same the other way round. $client = \Drupal:...


9

Thank you very much for your help. I finally manage to autenticate and retrieve files from my rpc server. Here is my syntax in case anyone needs it. // USER LOGIN $authenticate = xmlrpc($settings['server'], Array('user.login' => array($settings['user'] , $settings['password']),)); // CREATE HEADERS $options['headers']['Cookie'] = $authenticate['...


9

I was working on exactly the same thing the other day, the format is like this: http://domain.com/endpoint/taxonomy_term?parameters[vid]=2 To explain that a bit further... If you look at the code in _taxonomy_resource_definition() the index resource defines a few arguments: page (int) fields (string) parameters (array) pagesize (int) The way to pass any ...


8

Perhaps Services Views module could be of interest here: Views support for the Services module version 3.x and later. It has currently two features: - Create view based resource creating Services display in a view - Execute any view of the system via views resource call After enabling "views" resource in your services endpoint you can do ...


8

I've been surprised by the lack of documentation and general information about Drupal RESTful services. The best resources out there are from Tyler Frankenstein, the creator and maintainer of Drupalgap. Much thanks goes to Tyler as I started with his article here. Unfortunately, the documentation is rather old and no longer works with the current version ...


7

The flag service module (and probably the others you've listed in your comments) define their resources as actions, so you access them at a URL like: http://server/[endpoint]/[module]/[action].json. So for the flag action provided by the flag module that would be something like: http://server/endpoint/flag/flag.json This little snippet works well for ...


7

The index actually sends 20 results per page. I highly recommend you check out the ServicesResourceNodeTests.test file in the services module for a better explaination but basically you can pass the page number you want to get each page of results. The test file shows how it checks to see if the next page is empty: // The n+1 page should be empty. $...


7

For Drupal 7 and Services 7.x-3.x Step 1: Issue a post request to user.login resource with your username and password. If the login is successful, you will get a response object with 4 properties: session_name sessid token user (object) Screenshot from google chrome postman Step 2: Issue a post request to node with 2 headers Cookie: [session_name]=[...


7

You can check workflow steps First Time for login POST /services/session/token to retrieve CSRF Token POST myendpoint/system/connect with X-CSRF-Token header IF not Logged In Try Log in /myendpoint/user/login Log in Success and keep session_name=sessionid in Cookie Varible Future Launches POST /services/session/token to retrieve CSRF Token POST ...


6

Drupal's form API has CSRF protection built in, so submitting a form from an external domain won't work. You could either look at disabling the CSRF (very bad idea), or as you suggest, use the Services module. There's no one-to-one mapping between the services module and forms on the site, rather modules implement resources for certain tasks to be consumed ...


6

You'll first need to create a page(URL) in Drupal to get this parameters. You can do this by implementing hook_menu(), in your custom module. Refer this to create your custom module. function MYMODULE_menu() { $items['get_details'] = array ( 'title' => '', 'page callback' => 'MYMODULE_access_variables', 'page arguments' => array(1), ...


6

I had a requirement once like this where, using web service I have to create a node that will also save image. The following code uploads and saves image using web service. // File validator. $validators = array( /** * Defaults already allow png, jpg etc. If more needed to be supported, * edit here. */ 'file_validate_extensions' => array(), ...


6

it depends on the field widget how you submit your values for the service. For instance when you have a date field (datetime) with a select/dropdown widget, the form of the value should be the following: "field_date":{"und":[{"value":{"month":"3","year":"2013","day":"6","hour":"0","minute":"0","second":"0"}}]},


6

I found out how to do it, so I am posting it here in case it is helpful to somebody. Feel free to post if you know a better way. I assume you have created some content with fields corresponding to taxonomy vocabularies. Create a Services View Install the Services View module, as suggested in my previous comment. Go to Structure / Views / ...


6

You can't inject Drupal\Core\Database\Database, it's a container of static functions, constants, & variables for core database functions. If you'd like to inject the Connection object, that is be possible, and is more like something you want (unless you have scenario where setting.php is dynamic an all possible values of $schema can't be known). You ...


6

\Drupal::service('config.factory') and \Drupal::configFactory() are equivalent; the second is just shorter. There are many, many services provided by core, and only a few of them have a dedicated method. You can get a list of core services on the core.services.yml page. Note that this is not all services that core offers, for example, there are more ...


5

Short answer yes it does. There is a create raw method but unfortunately, it doesn't work very well b/c drupal 7s file handling is a joke. Ive created a patch that will allow you to attach files to a node and it uses multipart form, but its a work in progress. http://drupal.org/node/1484992


5

The following JSON appears to be the minimum you need to post a comment: { "nid":"1", "subject":"Comment Subject Text", "comment_body":{ "und":[{ "value":"Comment body text" }] } } Since there is no user, commenting on this "example.com/node/1" needs to be turned on and permissions for anonymous users to post comments need to be set.


5

All you need is to define your Resource, take a look at files in site/all/module/services/resources, you can find some examples, but for simplicity I will take you and example: endpoint_user moduel: endpoint_user.info file: name = endpoint_user description = endpoint_user core = 7.x endpoint_user.module file: <?php function ...


5

You can follow the function youtube_get_remote_image on how to make a call to youtube api and retrieve video length. Youtube public api provides this info without any authentication, for instance - http://gdata.youtube.com/feeds/api/videos/dc4UltkRJsw contains video length in the tag: yt:duration. I have not tested the below function, but should work. ...


5

Make sure "Save file information" is set for authenticated users


Only top voted, non community-wiki answers of a minimum length are eligible