Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Soap

245

Comments

  • Hi cyberde,
    Thanks for explaining, doh missed that an assumed the front page example was the same.

    I have copied the sample code to a page but now on execute I get -

    Parse error: syntax error, unexpected '{' "page path" on line 20.

    This points to the { brace after the try.

    If I take the try out of the equation, I get a -

    Fatal error: Cannot instantiate non-existent class: soapclient in "page path" Line 3

    I know this is something simple regards my lack of understanding, hope you have the patience!
    Regards
    Chris
  • Could you post your code please? Also does your PHP installation have the php_soap.dll extension enabled?
  • It isn't a windows server, it is a shared linux hosted platform.

    Shall I open a new ticket, save filling up your announcement post?

    Regards
    Chris
  • That might be a smart idea yea :)
  • Just as a last note, I think I have narrowed the problem down, SOAP is only supported in PHP5 and my host only provides PHP4 as default.

    So will have to migrate site to php5 before I can use soap, think I'll be busy testing tonight!
  • Rutter;16667 said:
    Just as a last note, I think I have narrowed the problem down, SOAP is only supported in PHP5 and my host only provides PHP4 as default.

    So will have to migrate site to php5 before I can use soap, think I'll be busy testing tonight!
    Okay, good to know :) There's also a php library that might work on PHP4, but don't remember the name though... (google :) )
  • trying to get this working

    Hi,

    I'm trying to get this working with PHP however I need some examples if you don't mind.

    Basically I want to submit a ticket on my customers behalf when they use our provisioning website, we will create a ticket using their email address, the subject of the ticket will be the provisioning reference number and then the content will contain their provisioning request. What i'd like to do is post this to osTicket and for osTicket to produce me with a ticket number so when clients look in the provisioning system, they can see a list of open or closed cases, secondly this will allow us to link the the case.

    I can't work out how to do this, I have uploaded the files, created an API key, but within the code it doesn't tell me if i need to create a new "staff" login that will be able to execute these instructions, nor does it say where the API key needs to go.

    Any help with doing these tasks would be much appreciated.

    thanks
    Barry
  • in addition

    In addition, this is what I have added:

    include('api/soap/lib/common.inc.php');

    $osticket = new SoapClient('http://support.blah.com/api/soap/index.php?wsdl');

    // Set up the parameters
    $args = array(
    'username' => 'WebService',
    'password' => 'MySecr3tp@ssword',
    'ticketId' => 34325
    );

    try {
    // Send the request and receive the status (eg Open, Closed)
    $result = $osticket->__call('ostTicket.getStatus',$args);
    }
    catch (SoapFault $e) {
    throw $e;
    }
  • bump

    sorry for third post, just subscribing to this thread and only way i know how to is to post
  • icepicknz;16716 said:
    sorry for third post, just subscribing to this thread and only way i know how to is to post
    Hi icepicknz,

    You don't need an API key anymore. I forgot to edit that line in the description on the osTicket SOAP MOD page. All you need is an staff-username and password in order to use the webservice.

    Also you do not need to include any files. All you need to do is to create a SoapClient which points to your installation. Also have a look at the examples given on my website.

    Another question though: where have you uploaded the files? You need to upload them to your osTicket installation.

    Cheers
  • working but not reply

    Hi,

    Thanks I've got it all working nicely, excepting ostTicket.postReply. If I use ostTicket.postMessage it works fine and inserts it into the ticket, however ostTicket.postReply requires a messageId, how is this generated and what do I use?

    I'd I just set a messageId of 2, the user receives the response in the email notification, but looking at the ticket there is no actual update.

    Thanks in advance
    Barry
  • in addition

    In Addition, I notice ostTicket.getInfo can't even tell me the messageID to us.

    Is anyone able to post replies to tickets using this SOAP API; what am I doing wrong?

    thanks
    barry
  • Hello,

    I can't request some info thought the SOAP ...

    Here my code :

    <?php
    $osticket = new SoapClient('http://osticket.domain.com/api/soap/index.php?wsdl');

    // Set up the parameters
    $args = array(
    'username' => 'mylogin',
    'password' => 'mypass',
    'ticketId' => 122
    );

    try {
    // Send the request and receive the status (eg Open, Closed)
    $result = $osticket->__soapCall('ostTicket.getStatus',$args);
    }
    catch (SoapFault $e) {
    throw $e;
    }
    ?>

    When I try to execute it :
    PHP Fatal error:  Uncaught SoapFault exception: [TICKET] Error in /home/seraphin/soap.php:13
    Stack trace:
    #0 /home/seraphin/soap.php(13): SoapClient->__soapCall('ostTicket.getSt...', Array)
    #1 {main}
    thrown in /home/seraphin/soap.php on line 13


    Can you post a standalone sample to request a ticket please ?

    Thanks a lot for your work ;)
  • icepicknz;16738 said:
    In Addition, I notice ostTicket.getInfo can't even tell me the messageID to us.

    Is anyone able to post replies to tickets using this SOAP API; what am I doing wrong?

    thanks
    barry
    This is how osTicket works. You need to get the list of messages. Each message has a message-id.
    In order to reply to a message you need to provide that msgId to ostTicket.postReply :) (normally the last question asked).
  • seraf;16745 said:
    Hello,

    I can't request some info thought the SOAP ...

    Here my code :

    <snip>
    When I try to execute it :
    [CODE]PHP Fatal error: Uncaught SoapFault exception: [TICKET] Error in /home/seraphin/soap.php:13
    Stack trace:
    #0 /home/seraphin/soap.php(13): SoapClient->__soapCall('ostTicket.getSt...', Array)
    #1 {main}
    thrown in /home/seraphin/soap.php on line 13
    Can you post a standalone sample to request a ticket please ?

    Thanks a lot for your work ;)
    Hi, after examining your code. I've noticed that you've used the internal ID of a ticket. You should use the external ID (355645) for example.
    The SoapFault exception also explains this if you process that exception (probably something like "ticket does not exist") :)

    You can always donate if you like my work :p

    [edit]
    I've updated that manual-page to include this information.
  • cant we
    cyberde;16746 said:
    This is how osTicket works. You need to get the list of messages. Each message has a message-id.
    In order to reply to a message you need to provide that msgId to ostTicket.postReply :) (normally the last question asked).
    Would it not be possible to add this to automatically get the message ID before posting, seems silly to have to grab the messageID when it's a constant value per ticket.

    I'e' I've noticed when I reply to ticket 45 I always need to use messageID 65, however I've not been able to find this value anywhere in the SOAP plugin, I had to login to osticket/scp/tickets.php and view the source of the reply where it gave me msgID.

    barry
  • in addition

    As the result from getmessages is in an array, are you able to give me example code of obtaining the messageID into a variable so it can be used for postReply.
  • it tried

    I tried doing ostTicket.getMessages on the ticket first in hopes it would give me the messageID for the ticket, but nope :/ Really stuck with this.
  • ok found workaround

    Ok, so I've found a workaround, not ideal but I guess incase anyone is wondering how to get the info to display in the ticket and how to get the customer to receive a ticket response.

    Simply use ostTicket.postMessage and this will update the ticket, obviously not the most ideal because it appears to have come from the client rather than a staff member, but at least you don't need a messageID and atleast the info gets displayed in the ticket.

    Next post the same message to the ticket but htis time as ostTicket.postReply and messageID 2 (worked for me), this will send the customer an email saying their ticket has been updated and include the content of the reply you wish to send.

    At least this way the client receives the response via email and the ticket is updated for future reference.

    Cheers
    Barry
  • icepicknz;16762 said:
    Would it not be possible to add this to automatically get the message ID before posting, seems silly to have to grab the messageID when it's a constant value per ticket.
    It's not a constant per ticket. Every ticket has different messageId's. When a customer posts a message via email or the webportal a new message is created with another ID.
    icepicknz;16765 said:
    As the result from getmessages is in an array, are you able to give me example code of obtaining the messageID into a variable so it can be used for postReply.
    You're right, the getMessages method doesn't return the messageId's. I will update the service to include this :)
    icepicknz;16766 said:
    I tried doing ostTicket.getMessages on the ticket first in hopes it would give me the messageID for the ticket, but nope :/ Really stuck with this.
    Please give me some time to response :p
  • Update relased: v1.2-42

    I've just released a new version containing the fix for messageId in getMessages.

  • listByStatusAndEmail

    Hi, I badly needed a function like listByStatusAndEmail, so I created one. I registered this new function in the index.php file and also created the function in ticket.class.php. However, when I try
    $result = $osticket->__soapCall( 'ostTicket.listByStatusAndEmail', $args );
    I get an exception thrown:
    method 'ostTicket.listByStatusAndEmail'/'listByStatusAndEmail'('ostTicket.listByStatusAndEmail') not defined in service/'ostTicket'('ostTicket' '.')


    Also,
    print_r( $osticket->__getFunctions() );
    returns:
    Array
    (
    [0] => DepartmentInfo ostDepartment.getInfo(string $username, string $password, int $departmentId)
    [1] => DepartmentInfoArray ostDepartment.listAll(string $username, string $password)
    [2] => boolean ostTicket.assign(string $username, string $password, int $ticketId, int $staffId, string $message)
    [3] => boolean ostTicket.close(string $username, string $password, int $ticketId)
    [4] => boolean ostTicket.delete(string $username, string $password, int $ticketId)
    [5] => TicketInfo ostTicket.getInfo(string $username, string $password, int $ticketId)
    [6] => TicketMessagesArray ostTicket.getMessages(string $username, string $password, int $ticketId)
    [7] => TicketNoteArray ostTicket.getNotes(string $username, string $password, int $ticketId)
    [8] => string ostTicket.getStatus(string $username, string $password, int $ticketId)
    [9] => TicketInfoArray ostTicket.listByStatus(string $username, string $password, string $status)
    [10] => TicketInfoArray ostTicket.listByStatusAndEmail(string $username, string $password, string $status, string $email)
    [11] => int ostTicket.open(string $username, string $password, TicketData $ticketData)
    [12] => int ostTicket.postMessage(string $username, string $password, int $ticketId, string $message)
    [13] => int ostTicket.postNote(string $username, string $password, int $ticketId, string $title, string $message)
    [14] => int ostTicket.postReply(string $username, string $password, int $ticketId, int $messageId, string $message)
    [15] => boolean ostTicket.release(string $username, string $password, int $ticketId)
    [16] => boolean ostTicket.reopen(string $username, string $password, int $ticketId)
    [17] => StaffInfo ostStaff.getInfo(string $username, string $password, int $staffId)
    [18] => StaffInfoArray ostStaff.listAll(string $username, string $password)
    [19] => TopicInfo ostTopic.getInfo(string $username, string $password, int $topicId)
    [20] => TopicInfoArray ostTopic.listAll(string $username, string $password)
    )


    The new function gets registered in the WSDL, but still SoapClient apparently does not recognize it.

    What am I doing wrong?
  • boteeka;16967 said:
    Hi, I badly needed a function like listByStatusAndEmail, so I created one. I registered this new function in the index.php file and also created the function in ticket.class.php. However, when I try
    snip
    I get an exception thrown:
    snip
    Also,
    snip
    returns:
    snip
    The new function gets registered in the WSDL, but still SoapClient apparently does not recognize it.

    What am I doing wrong?
    Sorry for the late reply, i was on vacation :)
    How did you register it in index.php?
  • wspl error firefox

    Hi,

    i have a question..when i trie to open wsdl by going to www.website.com/soap/api and click on wsdl it works fine in internet explorer, but firefox gives me this reply

    XML-parsefout: XML- of tekstdeclaratie niet aan begin van entiteit
    Locatie: http://www.website.com/api/soap/index.php?wsdl
    Regelnummer 2, kolom 1:<?xml version="1.0" encoding="UTF-8"?>
    ^

    i cant find what is wrong, hope you have a suggestion?

    thanks

    dennis
  • wsdl

    HI Cyberde,

    thanks for creating the soap mod. I have a small problem, (i hope) when i trie to open de wsdl in browser it tells me there is a xmp parsing problem. Opening the wsdl by www.yourwebsite.com/api/soap and click wsdl. I think i should get the xml document..but i get the xml parsing error. Seems there is something on line 1 and is is not the xlm / text declaration.
    Oh i use firefox as browser but i guess that should not be a problem.? Maybe someone else has had this problem too?

    grtz
  • That's weird, cause it validates here (using firefox). I am using the latest version available.
  • i have the latest version also... IE8 works, google chrome and firefox not...
    i setup a new test installation on www.beste-keuze.nl/test1/api/soap
    maybe you see something wrong there? it seems that i get a empty first line, could that be the problem?
  • Hmm, it seems it's something on your webhost:
    XML Parsing Error: XML or text declaration not at start of entity
    Checking the source of the XML file shows that the <?xml statement starts at the second line instead on the first line, making FireFox and Chrome bitch.
    That's most likely to be the problem indeed.

    Also Visual Studio doesn't like it: <blockquote class="Quote">
    The document at the url http://www.beste-keuze.nl/test1/api/soap/index.php?wsdl was not recognized as a known document type.
    The error message from each known type may help you fix the problem:
    - Report from 'DISCO Document' is 'Unexpected XML declaration. The XML declaration must be the first node
    I just chekced the sourcecode and there's no new-line infront of the <?xml tag, so it's definitely your webhost that's causing this somehow.
  • Ok thanks for the quick replies!! It is hosted om my own server, so must be possible to solve. I got no idea where to start, i hardly dare to ask but..maybe you have a idea?
  • Cyberde,

    i found out what the problem was :-) I am using a multi language version of ostickets. There where some extra lines in different files, solution was delete all de empty lines at the end of files. (after the ?> tag.. )So your work was good, the problem was in the NL version of ostickes!
Sign In or Register to comment.