tcdent/php-restclient

Removing extension form URI

Closed this issue · 1 comments

Hey,

I'm using your REST client to request an API with an old fashioned router, which does not really like the fact that the router appends '.json' at the end of the URI.

I use this simple code :

// Initialize the REST Client
$params = [
    'format' => 'json',
    'headers' => [
        'Content-Type' => 'application/json'
    ]
];

$this->credentials = $parameters["credentials"];

if(!empty($this->credentials["username"]) && !empty($this->credentials["password"])){
    $params = array_merge($params, $this->credentials);
}

$this->uri = $parameters['uri'];
$this->api = new RestClient($params);

// Call the API ($this->uri : http://localhost:8001)
$result = $this->api->get($this->uri . "/jobs");

Is there a way to remove the '.json' appended at the end of the URI ?

Just dont pass a format parameter when you initialize.