I am running into a weird issue -> I've got a controller set up to send a POST request to another application using GuzzleHttp - which works fine when this request is started from our VueJs client.
Now I am developing an Artisan Command (per request by the customer) to simplify calling this endpoint like 50+ times (as it generates videos) -> to call this endpoint I am using the following snippet as I am calling an internal controller:
$request = Request::create(
route('videos.new', [], false),
'POST',
[
// Some daata
]
);
$response = app()->handle($request);
$result = json_decode($response->getContent());
But the issue is, now the exact same code in that controller sends a GET
request instead of POST
to the other application and I cannot figure out why as the method is HARD CODED in there.
I know it's a GET
request as I am logging all requests entering the other application at the moment, url etc all looks correct, except that it's a GET
request now
Request send with:
$cdnReq = new \GuzzleHttp\Psr7\Request(
'POST',
"/generate/$type?" . http_build_query($query),
[
'Content-Type' => 'application/json'
],
json_encode($input)
);
$this->beforeRequest($cdnReq);
// Step 03: Send request to cdn
Log::debug("Request(" . $cdnReq->getMethod() . ") will be send to: " . $client->getConfig('base_uri') . $cdnReq->getUri(), $input);
$cdnRes = $client->send($cdnReq);
Does anyone have any idea why this is happening?
INFO: Laravel Version: Laravel/Framework 6.18.32
The issue was related to the URL being called as HTTP and redirected to HTTPS, which changes the POST to GET.