[solved] Curl Abfrage Fehler

Hilfe zu OTRS Problemen aller Art
steste123
OTRS ninja
Posts: 495
Joined: 25 Sep 2012, 19:04
OTRS Version?: OTRS Help Desk
Real Name: Stefan

[solved] Curl Abfrage Fehler

Postby steste123 » 11 Oct 2017, 17:44

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
Moderator
Posts: 983
Joined: 18 Dec 2007, 12:23
OTRS Version?: 4/5/6
Real Name: Roy Kaldung
Company: Znuny Inc.
Contact:

Re: Curl Abfrage Fehler

Postby root » 11 Oct 2017, 17:58

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.
OTRS 4/5/6 CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

You need professional services? Check out http://znuny.com/

steste123
OTRS ninja
Posts: 495
Joined: 25 Sep 2012, 19:04
OTRS Version?: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Postby steste123 » 11 Oct 2017, 18:21

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
Moderator
Posts: 13946
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: Curl Abfrage Fehler

Postby jojo » 11 Oct 2017, 21:56

"Production": OTRS Business Solution™ 6, STORM powered by OTRS
"Testing": OTRS git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

root
Moderator
Posts: 983
Joined: 18 Dec 2007, 12:23
OTRS Version?: 4/5/6
Real Name: Roy Kaldung
Company: Znuny Inc.
Contact:

Re: Curl Abfrage Fehler

Postby root » 12 Oct 2017, 07:22

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
OTRS 4/5/6 CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

You need professional services? Check out http://znuny.com/

jojo
Moderator
Posts: 13946
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: Curl Abfrage Fehler

Postby jojo » 12 Oct 2017, 09:31

Bei meinem System funktioniert der Request, allerdings darf für einen Kundenbenutzer nicht UserLogin genutzt werden. Siehe Docu aus meinem letzten Post
"Production": OTRS Business Solution™ 6, STORM powered by OTRS
"Testing": OTRS git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

steste123
OTRS ninja
Posts: 495
Joined: 25 Sep 2012, 19:04
OTRS Version?: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Postby steste123 » 12 Oct 2017, 15:20

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
Moderator
Posts: 983
Joined: 18 Dec 2007, 12:23
OTRS Version?: 4/5/6
Real Name: Roy Kaldung
Company: Znuny Inc.
Contact:

Re: Curl Abfrage Fehler

Postby root » 12 Oct 2017, 15:38

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
OTRS 4/5/6 CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

You need professional services? Check out http://znuny.com/

steste123
OTRS ninja
Posts: 495
Joined: 25 Sep 2012, 19:04
OTRS Version?: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Postby steste123 » 12 Oct 2017, 19:59

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
Moderator
Posts: 13946
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: Curl Abfrage Fehler

Postby jojo » 12 Oct 2017, 21:47

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

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

steste123
OTRS ninja
Posts: 495
Joined: 25 Sep 2012, 19:04
OTRS Version?: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Postby steste123 » 12 Oct 2017, 22:07

Danke jojo - erster Test sieht gut aus.

Werde weiter berichten!
OTRS 5.x - Debian 8 - apache 2.4 - MySQL 5.x

steste123
OTRS ninja
Posts: 495
Joined: 25 Sep 2012, 19:04
OTRS Version?: OTRS Help Desk
Real Name: Stefan

Re: Curl Abfrage Fehler

Postby steste123 » 13 Oct 2017, 12:46

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


Return to “Hilfe”

Who is online

Users browsing this forum: Bing [Bot], Lorsay and 5 guests