Sending Messages with Rest API

Is there a way to send REST API calls in AVEVA System Platform & OMI? I have seen some documentation on Rest API for Recipe Management and don't know if/how that would help me in this situation. After a button is clicked, I want to send a rest message with HTTP Post.

  • Hi Caroline,

    You should be able to use the WEBSVC OI Server for any REST API calls that you may have. AVEVA has a published user guide for WEBSVC, which you can find here: https://softwaresupportsp.aveva.com/#/producthub/document/details?id=0DE9F4E7-6934-4072-FDB2-08D8B7EA05EC

    Once you have the WEBSVC OI server setup, you should then be able to integrate the tag configurations within your SP/OMI application just like any other OI Server communication. 

  • Hi Caroline,

    As Adam suggest, the WEBSVC will allow you to do connections to webservice and get or set data and presenting it in a OI Driver like way.

    Funneling the data into datapoints you could use in your objects.

    But there is also possible to do this using scripting, the following example will utilize a RestSharp.dll and the newtonsoft library for working with json

    'REST API Call
    dim client as RestSharp.RestClient;
    dim request as RestSharp.RestRequest;
    dim response as RestSharp.RestResponse;
    
    client = new RestSharp.RestClient("http://api.openweathermap.org/data/2.5/forecast?q=London&mode=json&units=imperial&cnt=7&appid=3b8af615471033987fdaa4bf2ef93231");
    client.Timeout = -1;
    'System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 |System.Net.SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls13;
    request = new RestSharp.RestRequest(RestSharp.Method.GET);
    response = client.Execute(request);
    LogError(response.Content);
    
    Me.Result = response.Content;
    
    'JSON String parsing
    dim jinstance as Newtonsoft.Json.Linq.JObject;
    dim jarray1 as Newtonsoft.Json.Linq.JArray;
    
    jinstance = Newtonsoft.Json.Linq.JObject.Parse(response.Content);
    jarray1 = Newtonsoft.Json.Linq.JArray.FromObject(jinstance["list"]);
    
    
    'Assign values to Attibutes
    dim i as integer;
    for i = 0 to jarray1.Count - 1 step 1
    	Me.Humidity.Value[i + 1] = jarray1[i]["main"]["humidity"];
    	LogMessage(Me.Humidity.Value);
    	Me.Temperature.Max[i + 1] = jarray1[i]["main"]["temp_min"];
    	Me.Temperature.Min[i + 1] = jarray1[i]["main"]["temp_max"];
    
    next;
    Me.Run = false;

    I have some additional examples and files, but reach out to me (contact info in my profile) and I can send you some example files if you find it valuable.