1
SetTicketCustomFields always fails - anyone have an example?
Question asked by Speednet - 2/18/2019 at 3:31 PM
Answered
I'm having a huge amount of frustration trying to get the SetTicketCustomFields API call to work.  Every time it returns "Failed to set the custom fields for ticket number '_______' " with an error number "-2".

I have setup a custom field named "IP_Address" and assigned it to a custom template that is assigned to the receiving department.  I know it's setup correctly, because it shows up in the system interface for new tickets that are created.  (But it shows up as a blank value because I am unable to set it.)

I create the ticket (successfully) from the API, and grab the new ticket number in the return response.  Then I make another call to set the custom field value.

The SOAP request for call is:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">;
  <soap12:Body>
    <SetTicketCustomFields xmlns="http://www.smartertools.com/SmarterTrack/Services2/svcTickets.asmx">;
      <authUserName>__(username)__</authUserName>
      <authPassword>__(password)__</authPassword>
      <ticketNumber>__(ticket#)__</ticketNumber>
      <customFieldValues>
        <IP_Address>1.2.3.4</IP_Address>
      </customFieldValues>
    </SetTicketCustomFields>
  </soap12:Body>
</soap12:Envelope>
I have also (unsuccessfully) tried the customFieldValues as:

<customFieldValues>
  <string>IP_Address=1.2.3.4</string>
</customFieldValues>
(I tried this because the full specification literally says to do it.)

If someone could please insert a quick SOAP 1.2 example of a working SetTicketCustomFields request I would be grateful.

3 Replies

Reply to Thread
0
Speednet Replied
I checked the error log, and apparently there is an error within SmarterTrack.

Here is the error message for each test I have tried:

Failed to set the custom fields for ticket number '3C8-23FDFC24-0018'
Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at SmarterTrack.MRS.Services2.svcTickets.SetTicketCustomFields(String authUserName, String authPassword, String ticketNumber, String[] customFieldValues)
That's all the detail it provides.  Does this help figuring out what's happening?
0
Andrew Barker Replied
Employee Post Marked As Answer
Your second attempt with <string>IP_Address=1.2.3.4</string> used the correct structure. Without knowing more about your setup, it is difficult to say what the exact problem is, but I suspect that it is a mismatch in the custom field name. If you configured the custom field as "IP Address", then the value would need to be <string>IP Address=1.2.3.4</string>. Also, I noticed that the request you specified included several semi-colons which should be omitted. Your request should be something like:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">;
  <soap12:Body>
    <SetTicketCustomFields xmlns="http://www.smartertools.com/SmarterTrack/Services2/svcTickets.asmx">;
      <authUserName>__(username)__</authUserName>
      <authPassword>__(password)__</authPassword>
      <ticketNumber>__(ticket#)__</ticketNumber>
      <customFieldValues>
        <string>IP Address=1.2.3.4</string>
      </customFieldValues>
    </SetTicketCustomFields>
  </soap12:Body>
</soap12:Envelope>

Andrew Barker Software Developer SmarterTools Inc. www.smartertools.com
0
Speednet Replied
Thank you for the reply Andrew.

I'm not sure how the semicolons got into my code sample here, but they are not being sent with the request.  But it did make me scrutinize every character in the SOAP request, and I was able to find a couple of stray characters that were ruining the request.

Thanks as always for your help.


Reply to Thread