# API Invalid Signature on Routes with Request Query Parameters in Laravel PHP

**URL:** https://community.rapyd.net/t/api-invalid-signature-on-routes-with-request-query-parameters-in-laravel-php/59710
**Category:** 🙋🏽‍♀️🙋🏽‍♂️ Ask Questions
**Created:** [March 7, 2025, 1:25am UTC](https://community.rapyd.net/t/api-invalid-signature-on-routes-with-request-query-parameters-in-laravel-php/59710 "2025-03-07T01:25:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rp-lgvronqui](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@rp-lgvronqui](https://community.rapyd.net/u/rp-lgvronqui)
#### Post date: [March 7, 2025, 1:25am UTC](https://community.rapyd.net/t/api-invalid-signature-on-routes-with-request-query-parameters-in-laravel-php/59710/1 "2025-03-07T01:25:52Z")

</div>

I’m currently integrating Rapyd into our system and testing out different routes. I’ve used the base code from one of the tutorials for PHP and modified it to be more inline with our framework.

When visiting GET routes that do not have query parameters, the request is successful. It also works for sending POST requests. But on GET requests that have query parameters, I am currently getting an error code of UNAUTHENTICATED\_API\_CALL.

Here is the code for the service of connecting to Rapyd API.

```auto
class RapydService
{
    protected string $baseUrl;
    protected string $secretKey;
    protected string $accessKey;

    public function __construct()
    {
        $this->baseUrl = config('services.external.rapyd.api_url');
        $this->secretKey = config('services.external.rapyd.api_secret');
        $this->accessKey = config('services.external.rapyd.api_key');
    }

    private function generateString(int $length = 12): string
    {
        return Str::random($length);
    }

    public function makeRequest(string $method, string $path, array $body = []): array
    {
        $idempotency = $this->generateString();
        $salt = $this->generateString();
        $timestamp = now()->timestamp;

        $bodyString = !empty($body) ? json_encode($body, JSON_UNESCAPED_SLASHES) : '';
        $sigString = "{$method}{$path}{$salt}{$timestamp}{$this->accessKey}{$this->secretKey}{$bodyString}";
        $hashSigString = hash_hmac("sha256", $sigString, $this->secretKey);
        $signature = base64_encode($hashSigString);

        $response = Http::withHeaders([
            'Content-Type' => 'application/json',
            'access_key' => $this->accessKey,
            'salt' => $salt,
            'timestamp' => $timestamp,
            'signature' => $signature,
            'idempotency' => $idempotency
        ])->{$method}("{$this->baseUrl}{$path}", $body);

        if ($response->failed()) {
            throw new Exception("HTTP Request failed: " . $response->body());
        }

        return $response->json();
    }
}

```
