Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

We provide an API via Web-Service that can read and write tag values. To access the tags, a login is required for solution users. You can directly access this API through HTTP (REST API) connecting with a runtime system. 

This page presents information about how to use the WebAccess REST API.

On this page:

Table of Contents
maxLevel3
stylenone


Contract Methods Using Rest API

The Web-Server URLs have the following URL syntax "http://<IPAddress>/<ProductVersion>/WebAccessService.svc/<ContractMethod>" where the contract methods are described below.

SetServer

Defines the Server for following requests. 

GetVersion() 

Gets the service version.

Syntax:

Method: GET

URL Example:  http://localhost

/fs-8.1/WebAccessService.svc/GetVersion
  • Response Example:
  • Code Block
    {"GetVersionResult":2}

    Login(string userName, string password)

    Logs in project user. Parameters:

    • userName: User No case.
    • password: Password. Case

    Syntax:

    1. Method: GET
    2. URL Example: http://localhost/fs-8.1/WebAccessService.svc/Login?userName=guest password=test.
    3. Response Example:
    Code Block
    {
    "LoginResult":
    	{
    	"Handle": 2,
    	"Status": ""
    }
    }
    Returns the connection handle (whether >= 0) or error code (whether < 0).

    Logout(int handle)

    Logs out project user. Parameters:

    • handle: Connection. This value was returned by Login method.

    Syntax:

    1. Method: GET
    2. URL Example: http://localhost/fs-8.1/WebAccessService.svc/Logout?handle=1.
    3. Response Example:
    Code Block
    {
    "LogoutResult": 0
    }
    0: OK, 1: Invalid connection handle.

    ReadObject(int handle, string objectName)

    Reads value from specified object. Parameters:

    • handle: Connection. This value was returned by Login method.
    • objectName: Object (Tag) Name.

    :3101/rtServices/api/SetServer

    Code Block
    titleRequest
    Request/Headers
         . Content-Type: application/json
       . Request/Body
         . { "ModuleName": "Test", "UserName": "guest", "Password": "" }


    Code Block
    titleResponse
    Response/Headers
         . Access-Control-Allow-Origin: *
         . Access-Control-Allow-Headers: Content-Type, Content-Length, Authorization
         . Access-Control-Expose-Headers: Content-Type, Content-Length, Authorization
         . Access-Control-Allow-Methods: *
         . Content-Length: 0
         . Content-Type: application/octet-stream
         . Access-Control-Max-Age: 1728000
         . Authorization: Bearer c30730a4-e2ee-4595-9131-d64769c5afbe
         . Date: Tue, 28 Nov 2023 13:47:35 GMT
         . Server: TServer WebServer
       . Response/Headers
         . Nothing



    ReadObject

    Reads value from specified object:

    Syntax:

    Method: GET

    URL Example: http://localhost

    /fs-8.1/WebAccessService.svc/ReadObject?handle=1&objectName=tagExample.
  • Response Example:
  • Code Block
    {
    "ReadObjectResult":
    	{
    	"ObjectName": "tagExample",
    	"Quality": 64,
    	"UtcTimeStamp": "11/29/2019 17:33:47",
    	"Value": "0"
    }
    }
    Returns Value of the object.

    ReadObjects(int handle, IList<string> objectNames)

    Read value from a list of objects. Parameters:

    • handle: Connection. This value was returned by Login method.
    • objectNames: Objects (Tags) Name.

    Syntax:

    :3101/rtServices/api/SyncObjects/ReadObject

    Code Block
    titleRequest
    Request/Headers
         . Content-Type: application/json
         . Authorization: Bearer c30730a4-e2ee-4595-9131-d64769c5afbe
         . content-length: 25
       . Ex: .../api/SyncObjects/ReadObject?ObjectName=Tag1


    Code Block
    titleResponse
    Response/Headers
         . Content-Length: 89
         . Content-Type: application/json
         . Content-Encoding: utf8
         . Date: Tue, 28 Nov 2023 13:56:03 GMT
         . Server: TServer WebServer
       . Response/Body
         . { "ObjectName":"Tag1","Value":11,"Quality":192,"UtcTimeStamp":"11/28/2023 1:49:28.000 PM" }



    ReadObjects

    Reads value from multiple specified objects

    Method: GET

    Method: POST

    URL Example: http://localhost

    /fs-8.1/WebAccessService.svc/ReadObjects .
  • Body Example:
  • Code Block
    {
    "handle" : 1,
    "objectNames" :["tagExample1", "tagExample2"]}

    4. Response Example:

    :3101/rtServices/api/SyncObjects/ReadObjects

    Code Block
    titleRequest
    Request/Headers
         . Content-Type: application/json
         . Authorization: Bearer c30730a4-e2ee-4595-9131-d64769c5afbe
         . content-length: 25
       . Request/Body
         . { "ObjectNames": [ "Tag1", "Server.Now" ] }


    Code Block
    titleResponse
    Response/Headers
         . Content-Length: 89
         . Content-Type: application/json
         . Content-Encoding: utf8
         . Date: Tue, 28 Nov 2023 13:56:03 GMT
         . Server: TServer WebServer
       . Response/Body
         . [ {"ObjectName":"Tag1","Value":11,"Quality":192,"UtcTimeStamp":"11/28/2023 10:47:50.581 AM"},{"ObjectName":"Server.Now","Value":"11/28/2023 1:48:26.003 PM"} ]



    WriteObject

    Write value to a specified object

    Code Block
    {
    "ReadObjectResult":
    	{
    	"ObjectName": "tagExample1",
    	"Quality": 192,
    	"UtcTimeStamp": "02/12/2021 11:13:38",
    	"Value": "20"
    },
    {
     	"ObjectName": "tagExample2",
    	"Quality": 192,
    	"UtcTimeStamp": "02/12/2021 11:13:36",
    	"Value": "10" 
    }
    }
    Returns Value of the objects.

    WriteObject(int handle, ObjectItem item, bool force)

    Write value to specified object. Parameters:

    • handle: Connection. This value was returned by Login method.
    • item: Object (Tag) Name.
    • force: Flag to force value.

    Syntax:

    Method: POST

    URL Example:http://localhost

    /fs-8.1/WebAccessService.svc/WriteObject.

    :3101/rtServices/api/SyncObjects/WriteObject

    Code Block
    titleRequest
    Request/Headers
         . Content-Type: application/json
         . Authorization: Bearer c30730a4-e2ee-4595-9131-d64769c5afbe
         . content-length: 25
       . Request/Body
         . { "ObjectName" : "Tag1", "Value" : 11, 
  • Body Example:
  • Code Block
    {
    	"handle" : 1,
    	"item" : {
       	"ObjectName": "tagExample2",
    	"Quality": 192,
    	 "UtcTimeStampUtcTimestamp": "0211/1228/20212023 111:13:36",
    	"Value": "2"  
    	}
    	"force": false}49:28.000 PM" }


    Code Block
    titleResponse
    Response/Headers
         . Content-Length: 89
         . Content-Type: application/json
         . Content-Encoding: utf8
         . Date: Tue, 28 Nov 2023 13:56:03 GMT
         . Server: TServer WebServer
       . Response/Body
         . true



    WriteObjects

    Write value to specified objects

    4. Response Example:

    Code Block
    "WriteObjectResult": true
    Returns Flag indicating success or fail.

    WriteObjects(int handle, IList<ObjectItem> items, bool force)

    Write value to specified object. Parameters:

    • handle: Connection. This value was returned by Login method.
    • items: Object (Tag) Names.
    • force: Flag to force value.

    Syntax:

    Method: POST

    URL Example:http://localhost

    /fs-8.1/WebAccessService.svc/WriteObjects.

    :3101/rtServices/api/SyncObjects/WriteObjects

    Code Block
    titleRequest
    Request/Headers
         . Content-Type: application/json
         . Authorization: Bearer c30730a4-e2ee-4595-9131-d64769c5afbe
         . content-length: 25
       . Request/Body
         . { "ObjectList": [ {"ObjectName": "Tag1", "Value": 11 }, { "ObjectName": "Tag2", "Value": 2, 
    Code Block
    {
    	"handle" : 1,
    	"itens" : 
    	[{
       	"ObjectName": "tagExample1",
    	"Quality": 192,
    	"UtcTimeStamp": "02/12/2021 11:13:36",
    	"Value": "2"  
    	},
    	{
       	"ObjectName": "tagExample2",
    	"Quality": 192,
    	 "UtcTimeStamp": "0211/1228/20212023 1110:13:36",
    	"Value": "13"  
    	}],
    	"force": false}

    4. Response Example:

    18:22.260 AM" } ] }


    Code Block
    titleResponse
    Response/Headers
    . Content-Length: 89
    . Content-Type: application/json
    . Content-Encoding: utf8
    . Date: Tue, 28 Nov 2023 13:56:03 GMT
    . Server: TServer WebServer
    . Response/Body
    . [true,true] Code Block"WriteObjectsResult": [true, true] Returns Flag indicating success or fail.

    In this section:

    Page Tree
    root@parent
    spacesV10