0 Replies Latest reply on Mar 25, 2014 8:09 AM by saleemqamar

    WebHelpDesk Add techNote to existing ticket using C#

    saleemqamar

      Hi,

       

      How can I update a ticket using the API using C# .net.


      I am trying to follow the API from Web Help Desk API

      but it is not working.


      I am using the following code:

      json file:


      {
      "noteText": "Reinstalled the printer driver. Seems to be working fine now.",
      "jobticket": {

          "type": "JobTicket",

          "id": 43741

      },
      "isHidden": false,
      "isSolution": false,"billingRate": {

          "type": "BillingRate",

          "id": 1

        },

        "statusTypeId": 5,

        "emailClient": true,

        "emailTech": true,

        "emailTechGroupLevel": false,

        "emailGroupManager": false,

        "emailCc": false,

        "emailBcc": false,

        "ccAddressesForTech": "",

        "bccAddresses": ""

      }

       

      ********************

      public void addNoteToTicket2(string ticketNumber, string noteText, string jsonFile)

          {

              StreamReader streamReader = new StreamReader(jsonFile);

              string ticketContent = streamReader.ReadToEnd();

              streamReader.Close();

              byte[] data = Encoding.UTF8.GetBytes(ticketContent);

       

       

              String url = "https://whd-stg.qatar-med.cornell.edu/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets/" + ticketNumber + "?username=user1&password=ppp1234";

       

       

              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

              //request.PreAuthenticate = true;

              //request.Credentials = new NetworkCredential("username", "password"); ;

       

       

       

       

              //Need this to bypass "Invalid cert errors..."

              ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };

       

       

              request.ServicePoint.Expect100Continue = false;

              request.Method = "PUT";

              request.ContentType = "application/json";

              request.ContentLength = data.Length;

              request.Accept = "application/json";

       

       

              using (Stream stream = request.GetRequestStream())

              {

                  stream.Write(data, 0, data.Length);

                  stream.Close();

              }

       

       

              //HttpContext.Current.Response.AppendHeader("Content-Length", request.ContentLength.ToString());

              try

              {

                  HttpWebResponse response = (HttpWebResponse)request.GetResponse();

              }

              catch (Exception ex)

              {

       

       

                  Debug.WriteLine("ERROR: " + ex.Message);

              }

          }

       

      I am not getting any error but there is no NOTE being created in the system for that ticket.

       

      I am able create a NEW Ticket with no problem.

       

      Please help.

       

      Thx

       

      Saleem