Sending CustomerID to nph-genericinterface.pl

Moderator: crythias

Locked
tobylockyer
Znuny newbie
Posts: 2
Joined: 15 Aug 2012, 10:51
Znuny Version: 3.1.8
Real Name: Toby Lockyer

Sending CustomerID to nph-genericinterface.pl

Post by tobylockyer »

Hi Everyone, This is my first post, so I hope I've given all the information needed and someone can help me in posting the CustomerID to the ticket I'm creating, but I'm having trouble.

My Goal is to create a ticket (and add some Dynamic Fields)

I have the following in my SOAP call 'CustomerID' => $CustomerID,

Code: Select all

<?
error_reporting(E_ALL);
# Please define the connection information here:
$url      = "http://1.1.1.1/otrs/nph-genericinterface.pl/Webservice/Data/";
$username = "root";
$title    = "My Test Ticket via SOAP and PHP";
$from     = "me@myemail.com";
$NameSpace = 'Webste';
$CustomerID = "123456"; 
$Queue = "Postmaster";
$Operation = "TicketCreate";
//attachments
// Read in our file attachment
$attachment = file_get_contents('attachment.txt');
$encoded = base64_encode($attachment);
$attached = chunk_split($encoded);
$contenttype = "text/plain; charset=utf8";
$client = new SoapClient(null, array('location'  =>
$url,
                                     'uri'      => "CORE",
                                     'trace'    => 1,
                                     'style'     => SOAP_RPC,
                                     'use'       => SOAP_ENCODED));
$msg=array(new SoapParam('USERNAME', "UserLogin"),
new SoapParam('PASSWORD', "Password"),
new SoapParam(Array(
     	'CustomerUser'=> 'me@email.com,
		'ID'=> '1',     
		'UserID'=> '1',     
		'PriorityID' => '2',
        'Queue' => 'Postmaster',
        'State' => 'new',
        'Title' => 'Hello',
		'CustomerID' => $CustomerID,
            'Queue' => $Queue,
            'State' => 'new',
            'PriorityID' => 3

), 'ns1:Ticket'),
new SoapParam(Array(
        'CustomerID'=> 1,        
        'Body' => 'some body',
        'ContentType' => 'text/plain; charset=utf8',
        'Subject' => 'some subject',
        'TimeUnit' => '1',
        'TimeUnits' => 'minutes',
		'CustomerID', '8',
        'CustomerUser', '9',
        'OwnerID' , '10',
         'UserID', '11'
), 'ns1:Article'),
new SoapParam(Array(
        'Name' => 'streamtest',
        'Value' => 'OK',
), 'ns1:DynamicField'),

new SoapParam(Array(
        'Content' => $attached,
        'ContentType' => $contenttype,
        'Filename' => 'Attatchment.txt'
), 'ns1:Attachment')

);
$answer = $client->__soapCall('TicketCreate',$msg);

?>
The above code actually creates a ticket, (despite getting a soap error back) but the CustomerID is blank.


Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in /home/tl/otrs/make2.php:67
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://172.30.0...', 'CORE#TicketCrea...', 1, 0)
#1 /home/tl/otrs/make2.php(67): SoapClient->__soapCall('TicketCreate', Array)
#2 {main}
thrown in /home/tl/otrs/make2.php on line 67
You do not have the required permissions to view the files attached to this post.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Sending CustomerID to nph-genericinterface.pl

Post by crythias »

CustomerID doesn't appear to be a passed entry in TicketCreate (see http://dev.ortrs.org ) http://dev.otrs.org/3.1/Kernel/GenericI ... reate.html

The docs there seems to indicate that it's attempting to use
CustomerUserLogin => 'some customer login'
This would imply that the customer has already been created with a CustomerID, therefore use the CustomerUserLogin's CustomerID.

If not, well, it's a bug, but there is no provision for CustomerID, therefore what you're encountering is as programmed.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
tobylockyer
Znuny newbie
Posts: 2
Joined: 15 Aug 2012, 10:51
Znuny Version: 3.1.8
Real Name: Toby Lockyer

Re: Sending CustomerID to nph-genericinterface.pl

Post by tobylockyer »

Ah brill, and thanks for the link to the documentation. It will really help!

The transition from the old API to the new one was a bit weird for me!!

That's working now!! apart from the random soap error, but its making the call and using that ID, so I'll fix the Soap error!

Thanks again!! :D
leon
Znuny newbie
Posts: 7
Joined: 30 Oct 2012, 09:12
Znuny Version: 3.1.5

Re: Sending CustomerID to nph-genericinterface.pl

Post by leon »

Hey
I have a problem thats quiet similar.
In order to create a ticket I create an xml and send it to the webservice.
It looks like that:

Code: Select all

<TicketCreate>
      <UserLogin>{0}</UserLogin>
      <Password>{1}</Password>      
      <Ticket>
        <Title>{2}</Title>
        <Queue>{3}</Queue>
        <Lock>{4}</Lock>
        <State>{5}</State>
        <Priority>{6}</Priority>
        <Owner>{7}</Owner>
        <CustomerUser>{8}</CustomerUser>
      </Ticket>
      <Article>
        <Subject>{9}</Subject>
        <Body>{10}</Body>
        <ContentType>text/plain; charset=utf8</ContentType>
      </Article>      
    </TicketCreate>
With this xml I'm logging in as an agent. At that works fine and I can create a ticket. But the Customer ID is blank.
Now I changed the login to:

Code: Select all

<CustomerUserLogin>{0}</CustomerUserLogin>
And I'm sure that this customer exists! But instead of getting a WebResponse I get a WebException.
Where's my fault? :(
Locked