Kaseya Community

Anyone else having problems with the API?

This question is answered

Just curious if anyone else has experienced problems with the API?  We've been trying to get ConnectWise 2-way ticketing going for quite some time with no success.  It appears that the API is not working correctly.  We've had a ticket open with Kaseya for roughly four months now and have been told our issue has to go to engineering for a resolution.  I'm interpreting that as this being a system-wide issue.  I find it kind of hard to believe that no one else can use the API.

We've followed the instructions here: http://help.kaseya.com/WebHelp/EN/VSA/6050000/index.asp#4980.htm.  Something appears to be broken with the authentication mechanism.  When we authenticate to the api test page at https://server/vsaWS/testclient/testclient.asp, we get either a '0' or nothing in the Session ID field.  The remaining tests obviously fail with no Session ID.  Anyway, I'm hoping that someone here might be able to shed some light on this.  I'd rather use the API than email alerts.  We're on 6.5.

Verified Answer
  • Perfect.

    This is the reason why. You are attempting to log information into the header but it would be truncated due to the 2600 character limit.

    If you wish to try, I am giving this to you with NO GUARANTEE as this will be a sql modification.

    So if you try this it is at your own risk, please backup the database if you are not confident in your SQL skills.

    Now that you accepted that.... :)

    Go to SQL management studio and find that wsSession table. Rename the table to dbo.wsSession_OLD.

    Then open up a new Query window and paste the following in between *~*~*~*~*~*~ (do not copy these symbols into the SQL Management Studio query window:

    *~*~*~**~*~*~*~*~*

    USE [ksubscribers]

    GO

    /****** Object:  Table [dbo].[wsSession]    Script Date: 7/7/2014 9:41:45 PM ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[wsSession](

    [ID] [numeric](26, 0) IDENTITY(1,1) NOT NULL,

    [SessionId] [numeric](26, 0) NOT NULL,

    [hHeader] [varchar](max) NULL,

    [UserName] [varchar](100) NOT NULL,

    [IPAddress] [varchar](20) NOT NULL,

    [LastActivity] [datetime] NOT NULL,

    [BrowserIP] [varchar](20) NULL,

    [AppSessionId] [int] NULL,

    CONSTRAINT [PK_wsSession] PRIMARY KEY CLUSTERED

    (

    [ID] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    GO

    SET ANSI_PADDING OFF

    GO

    *~*~*~*~**~*~*~*~

    Execute this and it will recreate the table and index, this time converting your header into varchar(max).

    Then re-attempt the testclient.asp

    It should work now.

  • ahhhh yes the primary key is already written, as the table name was only re-written.

    Simply drop the table then, run this command first:

    drop table dbo.wsSession;

    Then run the create query I gave you before.

    Profit???

All Replies
  • Going to go through some basic troubleshooting steps just to make sure everything is in working order:

    1. Web services API is enabled?

    2. Can you hit the Service URL listed there locally from the server?

    Currently we have our TestClient.asp working so I know it seems like an environmental issue on your end.

  • Thank you for the reply.  

    1. If you are referring to the "Enable VSA API Web Service." checkbox on the System>Configure tab, yes.  It is enabled.

    2. If I hit the service URL locally from the server and logon using SHA-256, I get the same result - a '0' in the Session ID.  With SHA-1, the Session ID field remains empty.

  • Recreate a user account specifically for this test.

    Validate its credentials by logging into the VSA for the first time and then attempt the test one more time.

    Continue testing with SHA-256 for now to keep everything uniform.

  • By the way by hitting the service URL locally I do not mean "vsaws/testclient/testclient.asp"

    I mean can you bring up "http://localhost/vsaWS/KaseyaWS.asmx" from the Kserver and/or your endpoint by replacing the localhost with the hostname.

    Do you receive the web services page with the list of functions?

  • Thanks again.

    Yes, http://sitename/vsaWS/KaseyaWS.asmx returns the standards KaseyaWS page from an external browser and  http://localhost/vsaWS/KaseyaWS.asmx via IE on the KHost.

    I created new credentials, tested and instead of a '0', the Session ID now returns a blank field.

    Any idea where the logs for this functionality are located?

  • So i had been testing this out on our Dev server which is our 7.0 server.

    I have retested on our Kaseya 6.5 server and oddly received the same 0 Session ID.

    I proceeded to check the Config page and saw that our API was not selected.

    I know you stated you had your checkbox marked, but can we uncheck and re-check the box to force the DB entry to be updated.

    Then retest the form.

  • Thanks for the suggestion.  

    I unchecked/checked the box but the page still returns the same results.  

    Do you know if the KaseyaWStestClient c# app is supposed to work?  I tested that on the server and logging in via SHA-256 it returns an error message that is too large to fully display on the screen.  It begins with:

    System.Web.Services.Protocols.SoapException: Server was unable to process request. --->System.Exception: Error #8152: String or binary data would be truncated.

    The Statement has been terminated. on Line 22.

    It goes on displaying a load of XML data that I can't fully view to copy and paste to the forums.

    A quick search on the forums reveals this thread: community.kaseya.com/.../846.aspx

    I'm wondering if my DB is experiencing the same issue.  I've referenced the thread in my ticket with support.  The support tech I've been working with has been incredibly slow to get back to me though, so I may end up opening a new ticket.  I'll report back here if I hear anything.

  • Ok so first of all, we need to check if the API is even handing out a Session ID but not parsing it back to the UI.

    Can you go to the SQL Management Studio after you "authenticate" and query the following

    USE Ksubscribers;

    GO

    SELECT * FROM wsSession ORDER BY LastActivity DESC;

    This will give you a list of all the "active" sessionIDs for API given out.

    See if the timestamp of the LastActivity column matches the time you executed the authenticate procedure.

    If its handing out an ID, then we can see how we can investigate further.

  • Also looking at my "TestClient.asp" it has a modified date of Jan 2014, so these files have not been recently changed.

  • Thanks again.

    I ran the SQL Query and a session ID is definitely being generated for the test logon I created.  The timestamp matches the last attempted logon.

  • out of curiosity what is the column field information for the columns in this table?

  • 2014-07-07_21-29-16.png

    This is how my table looks like, just to make sure dataTypes and sizes are correct:

  • I hope this is what you want!

    ID,SessionID,hHeader,UserName,IPAddress,LastActivity,BrowserIP,AppSessionId

    ID is a number that increments on each new line

    Session ID appears to be a long number

    hHeader is NULL

    UserName is the user that I logged in as

    IP address is ::1 - I'm testing from the server

    LastActivity is the timestamp

    BrowersIP is ::1 and AppSessionId remains the same for each test for that user

  • Also can you post the complete exception when you run the c# program?

  • No look at the screenshot I posted in my previous response. It shows the actual DataTypes and field sizes...