This article provides resolutions to some common errors.  

API application could not connect to server. 


Error message from log file

...

Could not connect to SystemWeaver server!
SystemWeaver.ClientAPI.SWIOError: Error reading buffer: “Systemite.Lz4.Lz4” S

ystem.TypeInitializationException: “Systemite.Lz4.Lz4” 

System.IO.FileNotFoundException: Unable to load lz4 compression library

...

Resolution

Confirm that the server OS, the Visual C++ Redistributable for Visual Studio and the API application are all either 32 or 64 bit. A mismatch could be causing the problem. If the C++ Redistributable is missing, you will need to install it: 

Download Microsoft Visual C++ Redistributable for Visual Studio 2017


You may also need to have the vcruntime140.dll (also in the correct 32 or 64 bit version) in the same location.


When I try to run multiple calls from the API, the connection is unsuccessful. 


Error message from log file

"Multiple CallServerConnection avoided." 


Resolution

The SystemWeaver API doesn't support multi-threading for reading or writing. What this means, for example, is that if you use the GUI thread to login, it will use the GUI thread to execute events, and if you try to run something from another thread, these commands may be executed in parallel with events and you will possibly end up with invalid data in the cache.


One solution is to open up another connection to the server to execute long-running work. Even though the SWConnection object is a singleton, there is nothing that prevents you from creating a new connection:


SWConnection connection2 = new SWConnection();


Observe that if you open a second connection, it will be completely independent, with it's own cache. Also, login is a quite big operation, so you should only do this when you have a lot of work to do.


Parts are not created as expected. 

I have a parent item and I create subitems using the ClientAPI. The import is executed as expected. 

Then, I remove all of the parts (I do not delete them from the database) using an swExplorer client. 

I then create parts again using the ClientAPI. They are not created as expected, and I discover that the previous parts are no t removed from the parent item even though I removed them.


Resolution

The issue is that any change done in a console application only changes the content in the cache and is never pushed up to the server. For the changes to be pushed, you need to do a call to the server, the easiest way to do that is to send a ping to the server. A server call is also necessary to update the local cache of the console application. So if, for example, user1 (or app1) does a change then they need to ping the server to push it to server and if user2 (or app2) wants to get the user1 change, they would also need to ping the server to retrieve the information.


I am running Python version 3.9 and do not see all of the methods in the SystemWeaver.ClientAPI.


Resolution

When using Python 3.9 and later, and using functions such as item.GetPartItems(SID) or item.GetParts(SID), the returned object is a type IswObject instead of the expected IswItem and IswPart respectively. To handle this, the IswObject needs to be cast to the correct type which can be done with the following commands:


For IswItem:            
If isinstance(Item, IswObject):Item= IswItem(Item):

For IswPart:
If isinstance(part, IswObject):part = IswPart(part):