Skip to main content

ServiceAPI Usage Documentation

This documentation describes the use and configuration of the ServiceAPI class used in Synergy projects. ServiceAPI is an interface that provides access to the system through the REST API.

What is ServiceAPI?

ServiceAPI is a class that resides under the Bimser.Synergy.ServiceAPI namespace. This class is used to interact with forms and flows in Synergy projects. Through the ServiceAPI, data can be retrieved, updated, new forms can be created, flows can be initiated, and document management operations such as file operations can be performed.

Create ServiceAPI in Form with TokenAuthentication

To create the ServiceAPI using TokenAuthentication, you can follow these steps:

  1. Add the relevant using directives: ''csharp using Bimser.Synergy.ServiceAPI.Models.Authentication; using Bimser.Synergy.ServiceAPI;

  2. Define a method in the form that will instantiate the ServiceAPI: ''csharp private void CreateServiceApiInstance() { string webInterfaceUrl = "https://danismanlik.bimser.net/web/api"; var tokenAuthenticationParameters = new LoginWithTokenAuthenticationParameters { EncryptedData = Session.EncryptedData, Language = Session.Language, Token = Session.Token, }; ServiceAPI serviceApi = new ServiceAPI(tokenAuthenticationParameters, webInterfaceUrl); }

  3. Assign the URL of the REST API that the ServiceAPI will access to the webInterfaceUrl variable.
  4. Assign user login information (encrypted data, language, token) to the tokenAuthenticationParameters variable.
  5. Create a new instance from the ServiceAPI class, giving tokenAuthenticationParameters and webInterfaceUrl as parameters.

Create ServiceAPI in Streaming with TokenAuthentication

To create the ServiceAPI using TokenAuthentication, you can follow these steps:

  1. Add the relevant using directives: ''csharp using Bimser.Synergy.ServiceAPI.Models.Authentication; using Bimser.Synergy.ServiceAPI;

  2. Define a method in the form that will instantiate the ServiceAPI: ''csharp private void CreateServiceApiInstance() { string webInterfaceUrl = "https://danismanlik.bimser.net/web/api"; var tokenAuthenticationParameters = new LoginWithTokenAuthenticationParameters { EncryptedData = _workflowData.Context.EncryptedData, Language = _workflowData.Context.Language, Token = _workflowData.Context.Token, }; ServiceAPI serviceApi = new ServiceAPI(tokenAuthenticationParameters, webInterfaceUrl); }

  3. Assign the URL of the REST API that the ServiceAPI will access to the webInterfaceUrl variable.
  4. Assign the session information (EncryptedData, Language, Token) in _workflowData.Context to the tokenAuthenticationParameters variable.
  5. Create a new instance from the ServiceAPI class, giving tokenAuthenticationParameters and webInterfaceUrl as parameters.

Creating ServiceAPI with Basic Authentication

To create the ServiceAPI using Basic Authentication, you can follow these steps:

  1. Add the relevant using directives: ''csharp using Bimser.Synergy.ServiceAPI.Models.Authentication; using Bimser.Synergy.ServiceAPI;

  2. Define a method in the form or stream that will instantiate the ServiceAPI: ''csharp private void CreateServiceApiInstance() { string webInterfaceUrl = "https://danismanlik.bimser.net"; var basicAuthenticationParameters = new LoginWithBasicAuthenticationParameters { DomainAddress = webInterfaceUrl, Language = "en-US", Username = "The Username to Log In", password = "password of the logged-in user", RememberMe=false }; ServiceAPI serviceApi = new ServiceAPI(basicAuthenticationParameters, webInterfaceUrl); }
3. Assign the URL of the REST API that the ServiceAPI will access to the **webInterfaceUrl** variable.
4. Assign user login information (field name, language, username, password, remember) to the **basicAuthenticationParameters** variable.
5. Create a new instance from the **ServiceAPI** class, giving **basicAuthenticationParameters** and **webInterfaceUrl** as parameters.