Questions tagged [services]
The Services module provides a standardized solution for integrating external applications with Drupal.
681
questions
1
vote
0
answers
24
views
Which hook is invoked after an endpoint creates a node?
I am using Services 7.3x with Drupal 7. I have setup an endpoint that creates nodes. After a node is created by the endpoint, I would like to retrieve some data from the new node and update a third-...
0
votes
0
answers
64
views
Title field returning ' where apostrophe should be?
I have a series of fields on a View. For some reason, any node title field with an apostrophe in it is being returned to my endpoint as Jen's Cupcake Store instead of Jenn's Cupcake Store.
...
2
votes
1
answer
217
views
Return AccessDenied for custom page
I've setup a custom page in my system which is expecting 2 parameters that will be used to generate part of the content on that page, I'm able to retrieve the information from my page, but I'm ...
2
votes
1
answer
604
views
Which is better way of injecting service to controller with __construct or $instance = parent::create($container)
I'm always using this way of injecting service to controller:
<?php
namespace Drupal\TestModule\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\...
2
votes
2
answers
121
views
Retrieving nodes tagged by multiple terms
Let's say I have an articles content type, and a field_tags reference field (with multiple values referencing a "tag" vocabulary)
To retrieve articles referencing, say, "tag1" or &...
0
votes
0
answers
45
views
Post Data to D7 from D9
How do I post data from Drupal 9 when a content is created, post data to Drupal 7 hosted in a different server to create node content.
In Drupal7, I have enabled services module and created a resource ...
0
votes
1
answer
114
views
How to keep similar custom services from conflicting?
I have two modules, each of which is defining a normalizer service
module_one.services.yml
services:
module_one.normalizer.node_entity:
class: Drupal\module_one\Normalizer\...
2
votes
0
answers
589
views
Add custom Twig extension [closed]
I need to output a JSON variable in my theme, data is saved in a node field. I can easily use hook_preprocess_node to decode the data and save it in axillary variable and then render it using a custom ...
0
votes
1
answer
537
views
Uploading an image with JSON:API; getting "Access denied"
I'm attempting to upload an image with JSON:API.
I have added an Image field (not a media field) to the user entity.
In Postman, I get a session cookie for testing.
Then, in accordance with Flow 2 in ...
0
votes
0
answers
91
views
Discover custom services with drush generate
When I create a module and a custom service with drush generate and then create another service, also with drush generate, the first one is not available to inject.
What is missing to make it become ...
2
votes
0
answers
47
views
Make sure that the overriding service 'wins' [duplicate]
Setup
I have multiple sites that are very similar and therefore share the same code base. I have a custom module common with functionality common to all sites. Then for each site I have a specific ...
1
vote
0
answers
68
views
Decorating current_route_match service inexplicably causes fatal errors in webforms (and possibly elsewhere)
When decorating the current_route_match service I'm seeing issues with various webform requests (either fatal errors or ajax responses making no changes) when navigating past page two of a multi-page ...
0
votes
2
answers
144
views
Alter Services JSON Response
I have created a view to render all taxonomy terms and displayed it through a service. I have also created an endpoint in the service module to hit the url through firefox add-on RESTer to test the ...
1
vote
1
answer
1k
views
How to check config setting in custom service class with dependency injection?
In a custom Service class, I need to check a config setting.
I'm able to do this using \Drupal::config(static::SETTINGS) as documented here: https://www.drupal.org/docs/drupal-apis/configuration-api/...
0
votes
1
answer
488
views
How do I handle exceptions in a service class? [closed]
I have implemented a Service which does stuff with a RESTful API:
services:
api.clientname:
class: Drupal\my_custom_module\Api\Clientname
arguments: ['@http_client', '@messenger', '@logger....
0
votes
0
answers
72
views
REST API and Multi value date field
I have a React native front end with D7 backend. I am populating a content type that has a multi-value Date field. I am successfully creating the content-type with all other fields except the Date ...
1
vote
0
answers
63
views
When should I create a service for a class? [duplicate]
It seems that in Drupal code anything that is neither hook nor Plugin nor Controller nor any other thing with a standard functionality should be a Service.
For sure, services make sense when we want ...
1
vote
0
answers
141
views
What is the exact process of resetting a password using Node.js?
I am using Node js as front end and drupal as backend, i am trying to develop a reset password api. As per my finding there are three steps for the same.
Request a Password (Send an email with secure ...
0
votes
1
answer
15
views
I am unable to post image references
I have had this module working for years. Recently, it has stopped working. I'm using Services 3 to:
Log in and get a token
Create an image file and get its file ID
Create a node, using the file ID ...
0
votes
0
answers
31
views
Services module retrieve node with PHP text format
I have successfully connected to a Drupal instance using JSON and even retrieved a node using the service.
Problem is that the node has php content type, and the service returns the raw php content ...
1
vote
1
answer
23
views
Storage API + Services 3: How to work together?
I am trying to set up a site that will be storing a large amount of images. I am using Storage API module for that and It is working fine through web.
Now I need a REST Service to upload images.
I am ...
0
votes
1
answer
32
views
Prevent login except from Services
I would like to prevent my users to login except for those who login through my REST Service.
Is that possible?
1
vote
1
answer
24
views
How to add v1 when specifying the URL of an API?
I'm creating an API service using Services (Drupal 7) and would like to create an URL like /api/avu/v1/{id}.
I have api in Path to endpoint and in hook_services_resources() I have $resources['avu'] ...
0
votes
1
answer
50
views
Cannot assign roles creating User through REST endpoint
Sidenote, already seen this page, doesn't seem to help: How to create user with role(s) through REST service?
I've setup a new endpoint on my platform to try to allow a 3rd party to create users on ...
0
votes
1
answer
200
views
How can I pass parameters to a Services endpoint?
I have installed Drupal 7 and enabled Services in it. I have also created an endpoint /api/v2/ and in resources, I have allowed nodes to be listed as JSON.
I have sent a GET request using browser or ...
0
votes
1
answer
1k
views
How to create Dynamic Routes
I have been trying to create dynamic routes by using RouteSubscriberBase class.
I know we can create dynamic routes by using slug parameter in the URL. Similar to this method ( https://befused.com/...
11
votes
1
answer
2k
views
What is the difference between \Drupal::request()->getSession() and \Drupal::service('user.private_tempstore')?
As the title suggests, I'm a bit confused about those two methods of creating and accessing a session on Drupal 8. I'm not quite sure when to use the one over the other, could someone point me to the ...
-1
votes
1
answer
137
views
Let 'web-view' mobile iOS/Android app talk consume/feed site [closed]
I have a Drupal 8 site with the following modules:
HAL.
HTTP Basic Authentication.
REST UI.
RESTful Web Services.
Serialization.
Using the REST UI module, I configured it as follows.
Settings for ...
0
votes
1
answer
56
views
Order relationship in RESTful
I'm using https://www.drupal.org/project/restful module. I can sort base entity using annotation:
/**
* Class Things__1_0
* @package Drupal\restful_thing\Plugin\resource\node\thing
*
* @Resource(
...
-2
votes
1
answer
364
views
How to filter Data on the basis of id or uuid by Rest API?
I am using Drupal 8 I have installed the poll module.
I created a view with REST export enabled. Now when I get the data by this url
http://localhost/poll/rest/polling
I am getting all the data of ...
0
votes
0
answers
112
views
How to fetch field value via REST
I am using Drupal 8. I have installed the Rest module. I need to do polling so I also installed the Poll module. I created two questions with choices in poll and after that I created a view to show ...
3
votes
1
answer
103
views
Pass parameters for node access on RESTful call
I'm trying to figure out how to pass a filter parameter on a Services rest call. I've got a node of a specific type that I'd like to access through the Services module and rest. I'm testing with ...
2
votes
1
answer
21
views
Webservice args types automatic validation
It's a Drupal 7 with Webservices module, and there is a service with something like this (example):
'create-product' => array(
'operations' => array(
'create' => array(
'help' =&...
5
votes
1
answer
104
views
Module Uninstall Validators and Lazy Services
I have recently been working on creating functionality for a module that requires certain content related to the module be deleted before the module itself can be uninstalled.
https://www.drupal.org/...
0
votes
0
answers
86
views
Upload a JSON from a third party application
I have a client hosted on Acquia, and they are requesting that we implement functionality to allow another companies 3rd party application to upload a JSON file to an upload directory within their ...
1
vote
1
answer
1k
views
Dependency Injection if service exists
Is there any way to use dependency injection in a conditional way, i.e. only if a service exists similar to \Drupal::hasService().
I have a created a service in module A and in module B I have an ...
0
votes
1
answer
77
views
Can I connect via REST services with a mobile app I will develop?
I'm thinking of developing an e-commerce with Drupal 8 and Drupal Commerce, but I need to know if I can connect via REST services with a mobile app that I would develop too. The app would need to be ...
0
votes
1
answer
61
views
How can I get a user by email address using a service?
I have a custom service that I created to do some stuff with users. I want to be able to GET and DELETE users by email address because I may not know the uid.
I have the service set up now. It works ...
1
vote
1
answer
156
views
Redirect user on specified route
I know we can easily redirect a path to another path with Redirect module, but what I want to do is more complicated, my condition is when the user has a specified IP and the route is matched with to ...
0
votes
1
answer
228
views
Services module, custom endpoint & authentication
I have a have setup a custom endpoint via services and a REST server the custom end point looks like this,
https://website.local/api/v1/druaplsquare
The custom endpoint is built using the following ...
0
votes
1
answer
29
views
POST from external source
I have external site that needs to POST my drupal site (it basically shares data). I need to take the POST data parse it and create a node from it. Is this possible? I have created a PHP file ...
0
votes
1
answer
667
views
Add a condition to show menu link in YML
how should I do if I need to show to a link menu based on a condition ?
This is my YML for my menu link :
double_vue_klesia.backuserswitch:
title: 'Retour user précédent'
menu_name: navigation-...
2
votes
0
answers
43
views
how can I retrieve correct routes for rest resources?
I installed drupal 8 on my local server.
I enabled all web services modules and installed rest ui module.
I enabled some rest resources, such as entity/menu.
Now, I need to know how to get correct ...
3
votes
2
answers
367
views
Cannot update checkbox with services
I have been trying several configurations for trying to update a user account checkbox to uncheck it, with no success. I have been able to check it without issue.
updateCharType = function (token) {
...
0
votes
0
answers
107
views
delete or disable service endpoints programmatically?
I am trying to programmatically disable a service endpoint, but I am not able to achieve it using the following code.
$endpoint = services_endpoint_load('my_service');
$endpoint->disabled = TRUE;
...
0
votes
0
answers
318
views
How to create a table in second database with hook_schema
I want to use two databases, that works following: How can I setup multiple database connections in Drupal 8? .
I can set the connection in the settings.php file, access it by injecting a different ...
0
votes
0
answers
80
views
Is it possible to use taxonomy term's field as exposed filter in Services Views?
I would like create a REST endpoint which would allow a user to pass a query parameter that is incidentally a field of a taxonomy term. I am trying to achieve this by using Services Views in Drupal 7.
...
1
vote
1
answer
52
views
User registration through service
I have a local Drupal instance with services. I created an endpoint that has user resource included. I verified that all is well by logging in using the endpoint. I am now stuck at registering new ...
0
votes
1
answer
225
views
Retain content while deleting user using services
I need to delete a user account using services module & does it fine.
I can see that content(forum) created/updated by the user gets deleted.
Is it possible to achieve below screenshot option ...
0
votes
1
answer
53
views
How to programmatically submit a form that has a file-field using drupal_form_submit()?
I'm working to allow the submission of an existing form via REST using the Services module and drupal_form_submit(). Though this is reasonably routine, the form in question takes a file-upload which ...