saloonphp / saloon

🤠 Build beautiful API integrations and SDKs with Saloon
https://docs.saloon.dev
MIT License
2.09k stars 107 forks source link

GuzzleSender::createResponse(): Argument #2 ($guzzleResponse) must be of type Psr\Http\Message\ResponseInterface, null given #280

Closed ArjunKishore closed 1 year ago

ArjunKishore commented 1 year ago

I am using saloon 2 in plain PHP

I am getting the following error bit similar to issue here

Fatal error: Uncaught TypeError: Saloon\Http\Senders\GuzzleSender::createResponse(): Argument #2 ($guzzleResponse) must be of type Psr\Http\Message\ResponseInterface, null given, called in C:\Users\arj\Documents\mng-access\data\vendor\saloonphp\saloon\src\Http\Senders\GuzzleSender.php on line 120 and defined in C:\Users\arj\Documents\mng-access\data\vendor\saloonphp\saloon\src\Http\Senders\GuzzleSender.php:204 

Stack trace: #0 C:\Users\arj\Documents\mng-access\data\vendor\saloonphp\saloon\src\Http\Senders\GuzzleSender.php(120): Saloon\Http\Senders\GuzzleSender->createResponse() #1 C:\Users\arj\Documents\mng-access\data\vendor\saloonphp\saloon\src\Http\Senders\GuzzleSender.php(91): Saloon\Http\Senders\GuzzleSender->sendSynchronousRequest() #2 C:\Users\arj\Documents\mng-access\data\vendor\saloonphp\saloon\src\Http\Dispatcher.php(40): Saloon\Http\Senders\GuzzleSender->sendRequest() #3 C:\Users\arj\Documents\mng-access\data\vendor\saloonphp\saloon\src\Http\PendingRequest.php(459): Saloon\Http\Dispatcher->execute() #4 C:\Users\arj\Documents\mng-access\data\vendor\saloonphp\saloon\src\Traits\Connector\SendsRequests.php(33): Saloon\Http\PendingRequest->send() #5 C:\Users\arj\Documents\mng-access\data\vendor\saloonphp\saloon\src\Traits\Request\HasConnector.php(85): Saloon\Http\Connector->send() #6 C:\Users\arj\Documents\mng-access\data\npd.php(16): Saloon\Http\SoloRequest->send() #7 {main} thrown in C:\Users\arj\Documents\mng-access\data\vendor\saloonphp\saloon\src\Http\Senders\GuzzleSender.php on line 204
<?php

namespace Npd\Requests;

use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\SoloRequest;
use Saloon\Traits\Body\HasFormBody;

class CreateRefreshToken extends SoloRequest implements HasBody
{

    use HasFormBody;
    protected Method $method = Method::POST;
    protected string $username;
    protected string $password;
    protected string $client;
    protected string $integrator;
    private mixed $expiry;

    public function __construct(
        string $username,
        string $password,
        string $client,
        string $integrator,
        string $expiry,
    )
    {
        $this->username = $username;
        $this->password = $password;
        $this->client = $client;
        $this->integrator = $integrator;
        $this->expiry = $expiry;
    }

    /**
     * @inheritDoc
     */
    public function resolveEndpoint(): string
    {
        return 'https://auth.data.com/auth/session';
    }

    protected function defaultBody(): array
    {
        return [
            'username' => $this->username,
            'password' => $this->password,
            'client' => $this->client,
            'integrator' => $this->integrator,
            'expiry' => $this->expiry,
        ];
    }

}

Ctestapture

installing sammyjo20/saloon-http-sender didn't help me.

what am I missing ?

ArjunKishore commented 1 year ago

fixed it by update it to the latest version