How to use C# KayakoRestApi - CreateTicket ?

Discussion in 'Developing, APIs and extending' started by Revolver, Apr 14, 2012.

  1. Revolver

    Revolver Member

    I downloaded the KayakoRestApi.dll, but dont know how to start using it.

    Does anyone have sample c# code on how to use the "CreateTicket" methods?
  2. Revolver

    Revolver Member

  3. Revolver

    Revolver Member

    kayako technical support, does not know how to use it either :( at least provide a working example?
  4. Robert Merwin

    Robert Merwin Member

    Here is a little sample VS2010 program that creates a ticket. It may help you get started.
    To get it working, you need to use your API_KEY, SECRET_KEY and API_URL.

    In VS2010, add a reference to KayakoRestApi.dll. I put it in the .\bin\Debug folder with the program executable.
    Also, I had to change the default target framework in the project properties to .NET Framework 4, NOT: .NET Framework 4 Client Profile.

    Hope it works for you.

    Attached Files:

  5. Revolver

    Revolver Member

    Hi Robert,

    Thanks for the sample code,

    by the way what is this for...


    Does a ticket always need to be assigned to a staff? cant it be unassigned?
  6. Revolver

    Revolver Member

    What is staffuser?

    private static StaffUser registerStaffUser(string staffUsername)


    Does this method create a "staff" user or a regular user?

    private static void Create_Ticket_AutoUser(StaffUser staff)

    Does this method create a ticket for staff or a regular user?
  7. Revolver

    Revolver Member

  8. Robert Merwin

    Robert Merwin Member

    We need to assign each ticket to a "staff user" - so I was just looking up the staff. It's optional when creating a ticket.

    My example created a regular user, in addition to the ticket, and assigned the ticket to a staff user.

    Looking up a user can work the same way:

    Code:
            private static User FindUser(string username)
            {
                // GetUsers takes a Filter ID as an argument, but I haven't figured out how to define a filter yet.
                // GetUsers also lets you specify the maximum number of records to retrieve.
                foreach (User user in client.Users.GetUsers())
                {
                    if (user.FullName.CompareTo(userName) == 0)
                    {
                        Console.WriteLine("User {0}, {1} found.", user.Id, user.FullName);
                        return user;
                    }
                }
     
                return null;
            }
     
    
  9. Revolver

    Revolver Member

    Hold on a minute, isn't there a API for userSearch? http://wiki.kayako.com/display/DEV/REST - UserSearch?

    Although I cant find the UserSearch in the .NET SDK?
  10. Revolver

    Revolver Member

  11. Robert Merwin

    Robert Merwin Member

    Haven't gone there yet.
  12. Revolver

    Revolver Member

    Did you figure out how to use get ticket list?
  13. bergsj

    bergsj Member

    Hi there,

    I am trying to get my first ticket created by the C# SDK. However, every time I try to create it this is the resulting error:
    Anyone dealt with the same issue?
    Also tried Robert's .cs file, similair to my own test, but still the same error.
    Any help would by appreciated...:)

    Cheers!
  14. Cuong Le

    Cuong Le Member

    @bergsj: could you post your C# codes?
  15. bergsj

    bergsj Member

    Yes, here you go...

    Attached Files:

  16. Cuong Le

    Cuong Le Member

    Seems that the code is working, I'm trying to create user 'cs' which already exists in the system and I got this message. I can't create more users because there is no license left :)

    Attached Files:

  17. bergsj

    bergsj Member

    Cuong,

    Not sure what you mean. In my code I am trying to create a ticket, not a user.
  18. Cuong Le

    Cuong Le Member

    what is your args[] when you run the Main function? The app just quit because args is null.
  19. Cuong Le

    Cuong Le Member

    I test again and it works. The new ticket gets created, no problem. My command line args is: newticket 7
  20. bergsj

    bergsj Member

    What could be the reason for my exception. See screenshot...

    Attached Files:

Share This Page