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
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 ...
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 ...
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 &...
0 votes
4 answers
10k views

"An AJAX HTTP error occurred.HTTP Result Code: 200"

I'm new to Drupal, and I'm working with a Drupal site that someone else wrote. From the admin menu, when I go to Structure -> Pages -> Edit Content -> Gear Menu -> Edit (or Settings), Drupal throws up ...
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 ...
3 votes
1 answer
570 views

drupal_http_request() returns "Invalid JSON primitive"

I am developing a module for Drupal 7 which calls a remote API. I am using drupal_http_build_query(), drupal_http_request(), and drupal_json_decode(). My code is as follows $username = $form_state['...
-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. ...
1 vote
1 answer
2k views

Setting exposed filter default value from query string

I have a view which show products and an exposed filter block (category, manufacturer, price). I want to set category default value from URL, like this: /browse-products/category-id though, I wrote ...
-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 ...
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 ...
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\...
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: ...
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 ...
-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 ...
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['...
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 ...
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 ...
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,...
1 vote
1 answer
10k views

How do I send a drupal_http_request() with GET method?

Following examples found here and in API, I tried 2 methods, both return a bad request status message. First method $data = 'name=value&name1=value1'; $options = array( 'method' => 'GET', ...
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 ...
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 ...
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. ...
3 votes
1 answer
7k views

Guzzle httpClient Drupal Core throwing cURL error 28 Operation timed out

I have been loading the httpClient Core Service in a drupal 8 site. The service class works just fine when the request doesn't take too long from the API. It seems that if the request takes any longer ...
10 votes
5 answers
7k views

error 500: Premature end of script headers: index.php

Everything works except the /node/[nr]/edit page of only one content type page. And it's not for every page of this specific content type. Only one. So let's say I have a content type "product" and ...
1 vote
1 answer
1k views

Page redirect based on referrer

I am looking for an option to redirect user referred from a specific url (say abc.com) to domain.com/abc in Drupal 7 if http_referrer='abc.com' redirect to xyz.com/abc I looked at Redirect, http ...
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\...
0 votes
1 answer
1k views

HttpFoundation Request POST parameters

From VueJS, I am sending a POST HTTP request to my Drupal 8 controller. Here is my Controller: <?php namespace Drupal\mymodule\Controller; use Drupal\Core\Controller\ControllerBase; use Symfony\...
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: '', ...
5 votes
3 answers
3k views

How to issue 404 from a KernelEvents::REQUEST event

I'm trying to issue a 404 from a KernelEvents::REQUEST event, but it's resulting in the following error: Fatal error: Maximum function nesting level of '256' reached, aborting! in /var/www/vendor/...
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?
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, ...
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 ...
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 ...
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 ...
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 ...
10 votes
1 answer
2k views

Returning alternate HTTP codes for unpublished node

I'm trying to return the 404 page instead of 403 response for unpublished nodes in Drupal 8. I tested kernel response subscriber, but found the code I was using would only change the status code to ...
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 ...
-1 votes
1 answer
810 views

drupal_http_request give 400 response code for working url

I have major problem while getting response. I am using drupal_http_request to get the response but I get 400 as response though url given is working... I tried Curl Http Request module to overrride ...
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: [] ...
0 votes
3 answers
843 views

custom block menu path returns json Ok, but a 404 status header

I created a custom path via hook_menu with a page callback to a function that prints json. It all works in the sense that requesting: http://cms.tripchi.com/tripchi/getme returns my JSON, but the ...
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 ...
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 ...
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 ...
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" ...
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 { "...
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 ...
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 ...
10 votes
6 answers
4k views

Friendly error page to replace WSOD

This should be the easiest thing to do, but for some reason I just can't get it done. I'm trying to get a friendly static error page to replace nasty 500 scenarios. For now I'm just trying to ...
0 votes
0 answers
1k views

How to create custom pages for http 500 and 410 status errors? [duplicate]

In the site information section in the configuration, there is an option for setting the 404 page. But How will I set a custom page for http 500 and 410 error pages? Is there any specific module for ...
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 ...