amandiobm / rustici-engine-api-v2-client-php

Rustici Engine PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception when calling AboutApi->getAbout

vimal1234 opened this issue · comments

when we have pass username and password and our host url then get
Exception when calling AboutApi->getAbout: [401] Client error: GET http://rustici.xyz.net:8080/RusticiEngine/api/v2//about resulted in a 401 Unauthorized response: {"message":"Authentication Failed"}
which postman nicely work

Hey, this is how I set the configuration before sending the request.

use RusticiSoftware\Engine\V2\Configuration;
...
$configuration = new Configuration();
$configuration->setHost($this->config['host'] . '/RusticiEngine/api/v2');
$configuration->setAccessToken(null);
$configuration->setUsername($this->config['key']);
$configuration->setPassword($this->config['secret']);
Configuration::setDefaultConfiguration($configuration);

Let me know if that worked for you, if not, we will find a solution ;)

Best regards.

<?php
use RusticiSoftware\Engine\V2\Configuration;
require_once(__DIR__ . '/vendor/autoload.php');
// Configure HTTP basic authorization: basic


$configuration = new Configuration();

$configuration->setHost('http://rustici.sigmasolve.net:8080/RusticiEngine/api/v2'. '/RusticiEngine/api/v2');
$configuration->setAccessToken(null);
$configuration->setUsername('myusername');
$configuration->setPassword(my'password');
Configuration::setDefaultConfiguration($configuration);

$apiInstance = new RusticiSoftware\Engine\V2\Api\AboutApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    Configuration::getDefaultConfiguration()
);
$engine_tenant_name = "default"; // string | optional tenant for this request

try {
    $result = $apiInstance->getAbout($engine_tenant_name);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AboutApi->getAbout: ', $e->getMessage(), PHP_EOL;
}
?>

i have set debug true and i found below error
Warning: curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE* in C:\newxampp\htdocs\LMS\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 59
Exception when calling AboutApi->getAbout: [0] cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

So I saw a couple of errrors in your code.

When setting the host, you have the end part duplicated.

$configuration->setHost('http://rustici.sigmasolve.net:8080/RusticiEngine/api/v2'. '/RusticiEngine/api/v2');

It should be just
$configuration->setHost('http://rustici.sigmasolve.net:8080/RusticiEngine/api/v2');

and other thing is on the password.
$configuration->setPassword(my'password');

It should be
$configuration->setPassword(mypassword');`

I will set up a plain PHP file as you using, and test it.

Let you know my results