[solved] Curl Abfrage Fehler

Hilfe zu OTRS Problemen aller Art
Post Reply
steste123
Znuny wizard
Posts: 554
Joined: 25 Sep 2012, 19:04
Znuny Version: OTRS Help Desk
Real Name: Stefan

[solved] Curl Abfrage Fehler

Post by steste123 »

Erstelle aktuell Abfragen vom OTRS und werde bei folgendem Fehler verrückt.

CURL getinfo gibt mir aus:

Code: Select all

Array ( [url] => https://URL/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Session [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 317 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.152423 [namelookup_time] => 0.012551 [connect_time] => 0.030828 [pretransfer_time] => 0.076481 [size_upload] => 61 [size_download] => 0 [speed_download] => 0 [speed_upload] => 400 [download_content_length] => -1 [upload_content_length] => 61 [starttransfer_time] => 0.152395 [redirect_time] => 0 [certinfo] => Array ( ) [primary_ip] => xxxxx [primary_port] => 443 [local_ip] => xxxxx [local_port] => 60243 [redirect_url] => 
https://URL/otrs/nph-genericinterface.pl ist vorhanden

Jemand eine Idee?
Last edited by steste123 on 13 Oct 2017, 12:46, edited 1 time in total.
OTRS 5.x - Debian 8 - apache 2.4 - MySQL 5.x
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Curl Abfrage Fehler

Post by root »

Hi,

kannst Du da mal bitte etwas mehr Code zu liefern? Auch sieht nicht jeder gleich das da was mit PHP gemacht wird...
Zumindest wäre sowohl der eigentlich Request als auch auch der Fehler der mit curl_errno() bzw. curl_error() zurückkommt noch interessant.

- Roy

P.S.: Ich hab mal die IP-Adresse des Servers aus der Ausgabe entfernt.
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
steste123
Znuny wizard
Posts: 554
Joined: 25 Sep 2012, 19:04
Znuny Version: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Post by steste123 »

Stimmt :)

Code: Select all

curl -X POST https://URL/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Session?UserLogin=Kundenbenutzer&Password=Kundenbenutzerpasswort
curl_error: Empty reply from server
OTRS 5.x - Debian 8 - apache 2.4 - MySQL 5.x
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Curl Abfrage Fehler

Post by jojo »

"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Curl Abfrage Fehler

Post by root »

steste123 wrote:Stimmt :)

Code: Select all

curl -X POST https://URL/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Session?UserLogin=Kundenbenutzer&Password=Kundenbenutzerpasswort
curl_error: Empty reply from server
Hi,

also gibt es einen bestimmten Grund warum due URL-Parameter bei einem GET-Request nutzt? Gefühlt liegt hier das Problem für mich.

Und dann UserLogin = Agent, CustomerUserLogin = Kundenbenutzer

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Curl Abfrage Fehler

Post by jojo »

Bei meinem System funktioniert der Request, allerdings darf für einen Kundenbenutzer nicht UserLogin genutzt werden. Siehe Docu aus meinem letzten Post
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
steste123
Znuny wizard
Posts: 554
Joined: 25 Sep 2012, 19:04
Znuny Version: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Post by steste123 »

Also auch wenn ich CustomerUserLogin einsetze erhalte ich den Fehler.

Ich habe folgenden Request:

Code: Select all

curl -X POST https://URL/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/SessionCreate?CustomerUserLogin=Kundenbenutzer&Password=Kundenbenutzerpasswort
Den Webservice habe ich wie folgt konfiguriert:
Screenshot 1: https://imgur.com/a/1EfFz
Screenshot 2: https://imgur.com/a/qHJPX


Fehler:

Code: Select all

Unirest\Response Object ( [code] => 500 [raw_body] => HTTP::REST Error while determine Operation for request URI '/SessionCreate'. 
[body] => HTTP::REST Error while determine Operation for request URI '/SessionCreate'. 

gleicher Fehler wenn ich session nutze.
[headers] => Array ( [0] => HTTP/1.1 500 Internal Server Error [Content-Type] => text/plain; charset=UTF-8 [Content-Length] => 76 [Connection] => close ) ) 

No Session-ID return 
OTRS 5.x - Debian 8 - apache 2.4 - MySQL 5.x
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Curl Abfrage Fehler

Post by root »

Hi,

Wieso passt Dein Request, mit curl, eigentlich nicht zur Fehlermeldung (PHP, Unirest client)?

Ich denke am einfachsten ist es den Webservice mal zu exportieren und hier hochzuladen. und die dazugehörigen curl-Requests. Oder das PHP Skript.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
steste123
Znuny wizard
Posts: 554
Joined: 25 Sep 2012, 19:04
Znuny Version: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Post by steste123 »

Aufruf:

Code: Select all

https://URL/otrs/nph-genericinterface.pl/Webservice/testwebservice/Session?CustomerUserLogin=USER&Password=KENNWORT
Fehler:

Code: Select all

HTTP::REST Error while determine Operation for request URI '/Session'.
Client.php

Code: Select all

#!/usr/bin/env php
<?php
ini_set("display_errors",1);
ini_set("display_startup_errors",1);
error_reporting(E_ALL);

require_once __DIR__ . '/../vendor/autoload.php';
Unirest\Request::defaultHeader("Accept", "application/json");
Unirest\Request::defaultHeader("Content-Type", "application/json");
Unirest\Request::verifyPeer(false);

$BaseURL = 'https://URL/otrs/nph-genericinterface.pl/Webservice/testwebservice';
//GenericTicketConnectorREST
$headers = [];
$body = json_encode(
    [
        "CustomerUserLogin" => "CUSTOMER",
        "Password"  => "PASSWORT",
    ]
);
/**
 * SessionCreate
 *
 * http://doc.otrs.com/doc/api/otrs/stable/Perl/Kernel/GenericInterface/Operation/Session/SessionCreate.pm.html
 */

$response = Unirest\Request::post($BaseURL."/Session", $headers, $body);
echo $BaseURL."/SessionCreate";
print_r($response);
if (!$response->body->SessionID) {
    print "<br><br>No Session-ID return<br>";
    exit(1);
}
$SessionID = $response->body->SessionID;

echo $SessionID;

die();

/**
 * TicketSearch
 *
 * http://doc.otrs.com/doc/api/otrs/stable/Perl/Kernel/GenericInterface/Operation/Ticket/TicketSearch.pm.html
 */
$param = [
    'SessionID' => $SessionID,
    'StateType' => ['new', 'open'],
    'TicketCreateTimeOlderMinutes' => 1440,
];
$response = Unirest\Request::post($BaseURL."/TicketSearch", $headers, $param);
var_dump($response);

die();
/**
 * TicketCreate
 *
 * http://doc.otrs.com/doc/api/otrs/stable/Perl/Kernel/GenericInterface/Operation/Ticket/TicketCreate.pm.html
 */
$attachment = file_get_contents("example.bin");
$body = json_encode([
        'SessionID' => $SessionID,
        'Ticket' => [
            'Title' => 'Example ticket',
            'Queue' => 'Postmaster',
            'CustomerUser' => 'info@znuny.com',
            'State' => 'new',
            'Priority' => '3 normal',
            'OwnerID' => 1,
            'TypeID' => 1,
        ],
        'Article' =>[
            'ArticleSend' => 1,
            'ArticleTypeID' => 1,
            'SenderTypeID' => 1,
            'Subject' => 'Example',
            'Body' => 'This is a GenericInterface example.',
            'ContentType' => 'text/plain; charset=utf8',
            'Charset' => 'utf8',
            'MimeType' => 'text/plain',
            'To' => 'info@znuny.com',
        ]
    ]
);
$response = Unirest\Request::post($BaseURL."/Ticket", $headers, $body);
$TicketNumber = $response->body->TicketNumber;
$TicketID = $response->body->TicketID;
/**
 * TicketUpdate
 *
 * http://doc.otrs.com/doc/api/otrs/stable/Perl/Kernel/GenericInterface/Operation/Ticket/TicketUpdate.pm.html
 */
$param = json_encode([
    'SessionID' => $SessionID,
    'Ticket' => [
        'Queue' => 'Raw',
        'State' => 'open'
    ]
]);
$response = Unirest\Request::patch($BaseURL."/Ticket/${TicketID}", $headers, $param);
/**
 * TicketGet
 *
 * http://doc.otrs.com/doc/api/otrs/stable/Perl/Kernel/GenericInterface/Operation/Ticket/TicketGet.pm.html
 */
$param = [
    'SessionID' => $SessionID,
];
$response = Unirest\Request::get($BaseURL."/Ticket/${TicketID}", $headers, $param);
/**
 * TicketSearch
 *
 * http://doc.otrs.com/doc/api/otrs/stable/Perl/Kernel/GenericInterface/Operation/Ticket/TicketSearch.pm.html
 */
$param = [
    'SessionID' => $SessionID,
    'StateType' => ['new', 'open'],
    'TicketCreateTimeOlderMinutes' => 5,
];
$response = Unirest\Request::get($BaseURL."/Ticket", $headers, $param);
var_dump($response);
OTRS 5.x - Debian 8 - apache 2.4 - MySQL 5.x
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Curl Abfrage Fehler

Post by jojo »

Deine Webservice Config sieht Fehlerhaft aus, bitte lösche sie und importiere mal den Default. (https://raw.githubusercontent.com/OTRS/ ... orREST.yml)
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
steste123
Znuny wizard
Posts: 554
Joined: 25 Sep 2012, 19:04
Znuny Version: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Post by steste123 »

Danke jojo - erster Test sieht gut aus.

Werde weiter berichten!
OTRS 5.x - Debian 8 - apache 2.4 - MySQL 5.x
steste123
Znuny wizard
Posts: 554
Joined: 25 Sep 2012, 19:04
Znuny Version: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Post by steste123 »

Läuft alles. Vielen Dank!
OTRS 5.x - Debian 8 - apache 2.4 - MySQL 5.x
Post Reply