Questions tagged [http-request]

Use it for questions about HTTP requests, sending and receiving requests, status codes and more.

Filter by
Sorted by
Tagged with
-2 votes
1 answer
55 views

How to get multiple articles with specific ids via JSON:API in one request

how can I get multiple articles with specific ids in one request. I have tried lots of variations of https://website.com/jsonapi/node/article/aecc1a8b-b827-46a5-956b-16feb49e47c9 but without success. ...
Anatoli Asenov's user avatar
0 votes
0 answers
121 views

Using StreamedResponse for AJAX?

I am looking for a way with a Form API form in Drupal to have an #ajax event on a form field. When submitted, this calls a remote API. How can I stream the response out to the screen without the ...
Kevin's user avatar
  • 27.7k
1 vote
1 answer
103 views

Sub request doesn't take care of the language

I have defined a route as follow: mymodule.node_summary: path: '/node/{node}/summary' options: parameters: node: type: 'entity:node' defaults: _controller: '\Drupal\...
Baud's user avatar
  • 570
0 votes
0 answers
59 views

Specific CORS on a custom form POST request

I'm on D 9.3.x I have a custom form, e.g. my_module.my_form: path: 'custom-form-end-point' defaults: _title: 'Custom Form' _form: 'Drupal\my_module\Form\MyFormController' requirements: ...
Giuseppe's user avatar
  • 907
0 votes
1 answer
346 views

How to POST file with JSON:API in /jsonapi/file/file?

I tried with POSTMAN to upload a file to my endpoint host/jsonapi/file/file, the POST method is available but when I try to upload something, drupal gives me a 415 unsupported media type error. I ...
JPcode's user avatar
  • 1
-1 votes
1 answer
161 views

How to determine the cause of sudden "content encoding error"s for logged-in Drupal users? [closed]

One day last week or so, seemingly out of the blue, logged in sessions started to throw content encoding errors. The site still works fine for anonymous users. There's nothing in error_log, clearing ...
lynxlynxlynx's user avatar
1 vote
1 answer
581 views

Troubleshooting a Drupal HTTP 500 when there are no error log messages

I have reviewed some websites on how to troubleshoot HTTP 500 on a Drupal site and most often I have seen a PHP error by running drush ws in the console, however, I have been running into an oddity ...
Mark L's user avatar
  • 13
-1 votes
2 answers
1k views

How to pass and receive an http request body in GET?

I have two Drupal sites within one project. I want to send a GET request but I need to pass a lot of parameters. So instead of passing them in the query (which will lead to an extremely long URL), I ...
Sergey's user avatar
  • 51
2 votes
1 answer
206 views

$current_user->id() returns 0 when logged in for HTTP Middleware

I have injected currentUser as a dependency into my HTTP middleware, but when I check the UID while logged in, the result is always 0. I am logged in as an admin and refreshing the watchdog page; the ...
Patrick Kenny's user avatar
0 votes
1 answer
288 views

Circular reference detected for service "http_kernel" with middleware having the correct number of arguments

I'm pretty confused by this. I am experimenting with using an HTTP middleware to try to send Google Analytics page views from the server instead of the client. However, after adding a basic middleware,...
Patrick Kenny's user avatar
0 votes
0 answers
221 views

Troubleshooting Setting Cache Context to Session in Preprocess

My goal is to look for "webp" in the client HTTP_ACCEPT header in order to determine if I can serve WebP images. I chose this approach rather than using the WebP module because I thought it ...
user avatar
1 vote
0 answers
92 views

Custom module routing issue

I've a custom module where I have create the following route: my.custom.route: path: /{someVariable}/my-module/test defaults: _controller: '\Drupal\my_module\Controller\...
Paulo's user avatar
  • 11
0 votes
1 answer
183 views

Get client credentials from Simple Oauth module

I am creating user authentification with Drupal 9 + NuxtJS. Using Simple Oauth module and create post requests to oauth/token with data const data = { grant_type: 'password', client_id: '', ...
Вадим Гаджимурадов's user avatar
1 vote
1 answer
201 views

Use async with drupal_http_request()

I need to make an asynchronous call with drupal_http_request(). Is it possible?
user106028's user avatar
2 votes
1 answer
422 views

Can I use the session service directly instead of via the request?

The Drupal documentation on sessions mentions that sessions can be accessed via the Request object: Session data is accessed via the \Symfony\Component\HttpFoundation\Request::getSession() method, ...
Neograph734's user avatar
  • 8,379
0 votes
0 answers
52 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 ...
shablm's user avatar
  • 99
0 votes
0 answers
24 views

Delaying a Rules action until previous actions are complete

I'm making an HTTP request in an action which obviously takes some time. I want to use the response of that request in another action, but every time I get an error since the request hasn't completed ...
yuuuu's user avatar
  • 141
0 votes
1 answer
143 views

Decoupled site as a presentation (display) layer for external microservices?

I understand that Drupal 9 out of box is very capable as a decoupled aka headless Drupal serves as a back-end for other apps (the core REST, JSONAPI capability). However, I am thinking about the ...
gilzero's user avatar
  • 6,037
0 votes
1 answer
213 views

How to return Service Worker with custom HTTP header from custom module

I have a custom module providing a HTML5 Service Worker file under /modules/custom/my_blocks/assets/js/service-worker.js. Since the Service Worker is not located in the root of the Drupal server, I ...
david's user avatar
  • 184
1 vote
2 answers
379 views

Making an HTTP subrequest causes CurrentRouteMatch to have the wrong route

For complicated and unpleasant reasons[*], I want to embed entity data from the JSONAPI module inside JSON returned from a REST module resource. I am trying to do this by making an HTTP subrequest to ...
joachim's user avatar
  • 846
0 votes
1 answer
343 views

Render sub arrays with http client manger API calls response

I am trying to consume PokeAPI using Drupal. For making API calls I am using HTTP Client Manager module. I am able to set up initial configuration and get the data when the response field is a string. ...
miststudent2011's user avatar
2 votes
0 answers
61 views

How can I access nested data?

Im currently using Drupal's http client manager module to pull data from a json endpoint. I am having trouble getting this to work for a nested structure like this. { count: 2431 page_info: [] ...
tnum's user avatar
  • 21
2 votes
2 answers
1k views

Non-blocking HTTP request with Guzzle

Is there a Drupal 8 way to do non-blocking HTTP client request using Guzzle? I don't need to wait for the answer of The HTTP post, as that is slowing down the site. I already seen Non-blocking ...
lchabrand's user avatar
  • 364
0 votes
1 answer
207 views

How to force a JS library to be loaded via HTTPS?

How can I force a js library to always load only via SSL? Specifically, I want to get Drupal to always load stripe.js with SSL, because stripe.js refuses to load over http (you get a 403 FORBIDDEN ...
Patrick Kenny's user avatar
0 votes
1 answer
1k views

Cloudflare Clear Cache For One URL, Convert Curl Command to Drupal::httpClient() Or php

I am creating a custom module to clear caches on cloudflare for one url. The original curl command: curl -X POST "https://api.cloudflare.com/client/v4/zones/123456789/purge_cache" \ -H &...
Alaa Haddad's user avatar
1 vote
1 answer
162 views

Convert Acquia Clear Varnish For One URL Curl Command to Drupal::httpClient()

I am trying to convert a command to php curl or Drupal::httpClient(). The original command Curl -k -X PURGE -H "X-Acquia-Purge:[site-name]" --compressed -H "Host: example.com" ...
Alaa Haddad's user avatar
1 vote
1 answer
144 views

RuntimeException when patch submission. Module Webform Rest

When i send a PATCH request to my site to /webform_rest/{webform_id}/submission/{sid}?_format=json with the body { "data":{ "sincronizado":1 } } or { "...
mcventur's user avatar
1 vote
1 answer
85 views

Decoupled Drupal - Security: files structure

I am running a Drupal 8.9.2 site as a content repository accessed via an Angular 8 app. So there is one administrator who uses the Drupal interface to write content / upload files eccc.... and ...
elenat82's user avatar
1 vote
0 answers
55 views

Decoupled Drupal - Security [closed]

I am running a Drupal 8.9.2 site as a content repository accessed via an Angular 8 app. So there is one administrator who uses the Drupal interface to write content / upload files eccc.... and ...
elenat82's user avatar
0 votes
1 answer
483 views

Upload External File to Drupal File System

Situation I would like to be able to upload files programmatically from an external source to the drupal file system. I was thinking of making a RESTful API that allows me to save external files into ...
B. Cratty's user avatar
2 votes
1 answer
356 views

Alter Header Status Response to 410

I have several urls with "/tag/" string; some of them have content and some of them don't, so they return 404. How can I force them to return a 410 only for those that have no content? I ...
user99512's user avatar
0 votes
0 answers
80 views

Why is the Downloading file size unknown despite Content-Length headers set with file size in bytes?

During Downloading files the size is unknown "0B" despite having set the "Content-Length" headers with the bytes (see $http_headers below) Content-Type (String, 15 characters ) application/zip ...
Markus's user avatar
  • 113
1 vote
1 answer
684 views

How to handle the cache per user in REST Resource?

I have a requirement to expose a specific content type data via REST end point. Below is my code: public function get() { $current_user = $this->currentUser->id(); $user = $this->...
Suraj's user avatar
  • 884
0 votes
0 answers
986 views

Guzzle POST HTTPS requests return 403 Forbidden only when called inside PHPUnit tests

On one side I have a remote Drupal 8 (8.8.1) served via HTTPS which has the following endpoint: MODULENAME.get_notify: path: 'MODULENAME/get-notify' defaults: _controller: '\Drupal\MODULENAME\...
Roger's user avatar
  • 218
1 vote
0 answers
703 views

cant read current user in middleware

i am relatively new to drupal . thus i am trying to make an sso system work . i have this parent domain "domain.com" and the drupal site is running on sub.domain.com  . i can read the cookies and all ....
akramabdelrahman's user avatar
0 votes
2 answers
943 views

How to redirect the user to an external website with POST data?

I want to implement an offsite payment method and everything is going well except the fact that I can't find how to redirect the user to the offsite payment gateway after submitting the cart checkout ...
Sianurh's user avatar
0 votes
1 answer
1k views

How can I return a JSON response from an internal function ? (not the main callback)

I have a callback that is running for a specific post request. I am returning a certain JSON response at the end of it. What if I want to catch errors inside one of the functions that are ran in that ...
Yaron's user avatar
  • 263
0 votes
1 answer
1k views

How do I handle an incoming POST request in a module?

I am really new to Drupal but I have to do a project using it and I was just wondering how to handle an incoming POST request in a module: I am creating a module that will get incoming data from a ...
T Kharel's user avatar
0 votes
0 answers
324 views

How to Resolve CORB Issue using Drupal Docker Container

I'm running the latest version of the Drupal docker container. I'm trying to make a GET API call via Javascript and I'm receiving back CORB (cross-origin-read-blocking) errors in the Console when ...
jeffnaismith_design's user avatar
1 vote
1 answer
863 views

How to get the uncached version of request headers?

We need to programmatically get the request headers using the mymodule_preprocess_page hook. To do this we tried the following, however, because we have CDN, Varnish, and Drupal Cache all enabled, the ...
usernameabc's user avatar
  • 2,676
0 votes
0 answers
51 views

Help needed with ajax request from Jquery to callback function

I create the callback url 'swish_payment/request' in my hook_menu() function: function swish_payments_menu(){ $items['swish_payment/request'] = array( 'type' => MENU_CALLBACK, ...
TBJ's user avatar
  • 606
2 votes
2 answers
825 views

Hide title if 404 error

I have a custom 404 error page, and I just want a quick module that hides the 404 page title, if the user arrives at a 404 error. I've found a D7 function that looks like it would work, checking for ...
turpentyne's user avatar
1 vote
2 answers
407 views

WSOD while sending headers, probably Cache-related

I have a very strange problem with a fresh Drupal install: On some pages, I receive a WSOD with ERR_EMPTY_RESPONSE: It happens for instance when on admin/config/development/performance I click Clear ...
Georg Jähnig's user avatar
2 votes
1 answer
446 views

How to add certificate to drupal_http_request()?

I am currently setting up a payment method in my Drupal 7 site and following the API documentation for the service I could use this cURL command for testing purposes: $ curl -s -S -i --cert ./...
TBJ's user avatar
  • 606
2 votes
0 answers
232 views

How do I access data nested within JSON in a Guzzle service description response model? [closed]

I'm trying to pull some data into Drupal from a service, via Guzzle. I've got several clients like this working, but the data returned by this service is structured a bit differently: { pager: [ ], ...
WRD's user avatar
  • 187
0 votes
1 answer
153 views

Securing Admin on separate port

I am attempting to secure the admin pages (/admin/*) and login page (/user/login) to port 8443. I have successfully done that with the following in apache 2.4: <VirtualHost _default_:443> ...
Taylor's Designs's user avatar
1 vote
1 answer
2k views

Drupal::httpClient() and proxy settings

I've defined a proxy in my settings.php: $settings['http_client_config']['proxy']['http'] = 'http://ip:port'; $settings['http_client_config']['proxy']['https'] = 'http://ip:port'; $settings['...
AndyLicht's user avatar
1 vote
1 answer
1k views

HTTP Client Manager $request->getStatusCode() == 200 return?

When I read this HTTP Client Manager docs on Drupal, I don't understand why it returns the $build when $request->getStatusCode() == 200, is that supposed to be not equal 200? I also copy and paste the ...
Jiang Zhan's user avatar
0 votes
1 answer
229 views

Get data from remote REST API (read only)

We use a remote service (not Drupal) to publish press releases and to show those releases in a remote newsroom. This remote service offers an API so we should be able to fetch and show the newsroom ...
TBJ's user avatar
  • 606
0 votes
2 answers
3k views

How to get and apply current page query parameters from current AJAX request

I'm having a hard time figuring out how to do this. Essentially I have a table displaying users on a page. The table is paginated with the PagerExtender and sortable with the TableSortExtender. Each ...
joegl's user avatar
  • 175