Class RevitServerApi
- Namespace
- RevitServerNet
- Assembly
- RevitServerNet.dll
Main class for working with Revit Server REST API
public class RevitServerApiInheritance
Inherited Members
Extension Methods
Constructors
RevitServerApi(string, string, bool, string)
Initializes a new instance of RevitServerApi
public RevitServerApi(string host, string userName, bool useHttps = false, string serverVersion = "2019")Parameters
hoststring-
Revit Server host (e.g. "localhost" or IP address)
userNamestring-
User name for API requests
useHttpsbool-
Use HTTPS (default: false)
serverVersionstring-
Server version (default: "2019")
Properties
BaseUrl
Base URL for API
public string BaseUrl { get; }Property Value
Timeout
Time limit of one REST request, from sending it to reading the whole response. When it elapses the request is aborted and a RevitServerNet.RevitServerApiException is thrown; System.Threading.Timeout.InfiniteTimeSpan means no limit. null (the default) keeps the behaviour of the platform, as before this property existed: on .NET 6/8 HttpWebRequest ends a request after 100 s, on .NET Framework its async calls have no limit.
public TimeSpan? Timeout { get; set; }Property Value
UserName
User name
public string UserName { get; }Property Value
Methods
DeleteAsync(string, Dictionary<string, string>)
Performs DELETE request to API
public Task<string> DeleteAsync(string command, Dictionary<string, string> additionalHeaders = null)Parameters
commandstring-
API command
additionalHeadersDictionary<string, string>-
Additional headers
Returns
DeleteAsync(string, Dictionary<string, string>, CancellationToken)
Performs DELETE request to API; the request is aborted when cancellationToken is cancelled
public Task<string> DeleteAsync(string command, Dictionary<string, string> additionalHeaders, CancellationToken cancellationToken)Parameters
commandstringadditionalHeadersDictionary<string, string>cancellationTokenCancellationToken
Returns
EncodePath(string)
Encodes path in API format: replaces separators with |, then percent-encodes every folder/model name (segment between |) with System.Uri.EscapeDataString(System.String). The | separator itself is kept as is.
public static string EncodePath(string path)Parameters
pathstring-
Path to file or folder with raw (unescaped) names, e.g. "|#Archive|Model.rvt"
Returns
- string
-
URL path segment ready to put into a command, e.g. "|%23Archive|Model.rvt"
GetAsync(string, Dictionary<string, string>)
Performs GET request to API
public Task<string> GetAsync(string command, Dictionary<string, string> additionalHeaders = null)Parameters
commandstring-
API command
additionalHeadersDictionary<string, string>-
Additional headers
Returns
GetAsync(string, Dictionary<string, string>, CancellationToken)
Performs GET request to API; the request is aborted when cancellationToken is cancelled
public Task<string> GetAsync(string command, Dictionary<string, string> additionalHeaders, CancellationToken cancellationToken)Parameters
commandstringadditionalHeadersDictionary<string, string>cancellationTokenCancellationToken
Returns
PostAsync(string, string, Dictionary<string, string>)
Performs POST request to API
public Task<string> PostAsync(string command, string data = null, Dictionary<string, string> additionalHeaders = null)Parameters
commandstring-
API command
datastring-
Data to send
additionalHeadersDictionary<string, string>-
Additional headers
Returns
PostAsync(string, string, Dictionary<string, string>, CancellationToken)
Performs POST request to API; the request is aborted when cancellationToken is cancelled
public Task<string> PostAsync(string command, string data, Dictionary<string, string> additionalHeaders, CancellationToken cancellationToken)Parameters
commandstringdatastringadditionalHeadersDictionary<string, string>cancellationTokenCancellationToken
Returns
PutAsync(string, string, Dictionary<string, string>)
Performs PUT request to API
public Task<string> PutAsync(string command, string data = null, Dictionary<string, string> additionalHeaders = null)Parameters
commandstring-
API command
datastring-
Data to send
additionalHeadersDictionary<string, string>-
Additional headers
Returns
PutAsync(string, string, Dictionary<string, string>, CancellationToken)
Performs PUT request to API; the request is aborted when cancellationToken is cancelled
public Task<string> PutAsync(string command, string data, Dictionary<string, string> additionalHeaders, CancellationToken cancellationToken)Parameters
commandstringdatastringadditionalHeadersDictionary<string, string>cancellationTokenCancellationToken