Creating an API Client Using Microsoft .NET

Since the Crestron Fusion API Server is REST-based, the following .NET components are recommended for creating requests and interpreting server responses over HTTP:

  • System.NET.WebRequest sends an HTTP resource operation request to the Crestron Fusion API server consisting of a URI, Verb, and Content. Set the ContentType property to JSON or XML.
  • System.NET.WebResponse reads the HTTP responses to client requests. The responses from the Crestron Fusion API server typically consist of an HTTP status code and content wrapped in an API_Response object.
  • System.XML.Serialization.XMLSerializer provides functionality to convert XML into a fully typed instantiated class that is based on entity models provided in the framework.
  • System.Runtime.Serialization.Json.DataContractJsonSerializer provides functionality to convert JSON into a fully typed instantiated class that is based on entity models provided in the framework.

Usage of these classes is highlighted in the .NET test harness sample code in the JsonHelper and HTTPHelper classes.