[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name ‘oauth_clients’

  laravel, php, sql-server

Server and client machine in same machine. Database in different server. I am using wamp server with windows server 2012.

I tried many version of ODBC drivers like 13,15,17.. And all returns same error.

Also i tried with other programs, here is the results:

Postman works.

Curl works.

Guzzle does not work.

ps.: I am using nginx proxy manager, i redirect to http to https on nginx proxy manager.

<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"https://test.com/oauth/token");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "grant_type=password&client_id=3&client_secret=xxxx&[email protected]&password=password");

// In real life you should use something like:
// curl_setopt($ch, CURLOPT_POSTFIELDS, 
//          http_build_query(array('postvar1' => 'value1')));

// Receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec($ch);

curl_close ($ch);

// Further processing ...
var_dump($server_output);

This above code works in same server.

This one returns an error: invalid object name ‘oauth_clients’

$client = new Client([
            'base_uri' => config('api.base_uri'),
            'curl' => [
                CURLOPT_CAINFO => base_path('resources/certs/cacert.pem')
            ]
        ]);

        if (method_exists($this, 'resolveAuthorization')) {
            $this->resolveAuthorization($queryParams, $formParams, $headers);
        }

        $bodyType = 'form_params';

        if ($hasFile) {
            $bodyType = 'multipart';

            $multipart = [];

            foreach ($formParams as $name => $contents) {
                $multipart[] = ['name' => $name, 'contents' => $contents];
            }
        }

        $response = $client->request($method, $requestUrl, [
            'query' => $queryParams,
            $bodyType => $hasFile ? $multipart : $formParams,
            'headers' => $headers,
        ]);

        $response = $response->getBody()->getContents();

        if (method_exists($this, 'decodeResponse')) {
            $response = $this->decodeResponse($response);
        }

        if (method_exists($this, 'checkIfErrorResponse')) {
            $this->checkIfErrorResponse($response);
        }

        return $response;

I also changed protected $table="oauth_clients" to protected $table="[dbo].[oauth_clients]" and different versions. But same error returns.

Source: Laravel

Leave a Reply