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.
I can't figure out what exactly I can do with $parameter when I use these methods.
Can I somehow use this parameter for sending custom headers?
Comments
Comment #1
voxpelli CreditAttribution: voxpelli commentedThe $parameter variable is for query parameters - those parameters that are part of the url - eg. "name" in "http://example.com/?name=123".
To add headers you would need to create the HttpClientRequest object yourself - the get(), post() etc are just shortcuts for creating a HttpClientRequest object and executing it in the HttpClient object.
This is probably how you should create a HttpClientRequest:
Comment #2
vaidik CreditAttribution: vaidik commentedWell this is what I was doing and it worked!
I was sort of sure that get(), post(), etc. would not be able to do this. Still confirmed it.