Here are the examples of the csharp api class RestSharp.RestRequest.AddJsonBody(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
35 Examples
0
1. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultExtensionMethodOperations.cs
Source File: MFWSVaultExtensionMethodOperations.cs
public async Task<TA> ExecuteVaultExtensionMethodAsync<TA, TB>(string extensionMethodName, TB input = null, CancellationToken token = default(CancellationToken)) where TA : new() where TB : class { // Create the request. var request = new RestRequest($"/REST/vault/extensionmethod/{extensionMethodName}"); // If we have a parameter then serialise it. if (null != input) { request.AddJsonBody(input); } // Make the request and get the response. var response = await this.MFWSClient.Post<TA>(request, token) .ConfigureAwait(false); // Return the data. return response.Data; }
0
2. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultExtensionMethodOperations.cs
Source File: MFWSVaultExtensionMethodOperations.cs
public async Task<string> ExecuteVaultExtensionMethodAsync<TB>(string extensionMethodName, TB input = null, CancellationToken token = default(CancellationToken)) where TB : class { // Create the request. var request = new RestRequest($"/REST/vault/extensionmethod/{extensionMethodName}"); // If we have a parameter then serialise it. if (null != input) { request.AddJsonBody(input); } // Make the request and get the response. var response = await this.MFWSClient.Post(request, token) .ConfigureAwait(false); // Return the data. return response.Content; }
0
3. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultObjectOperations.cs
Source File: MFWSVaultObjectOperations.cs
public async Task<ObjectVersion> SetCheckoutStatusAsync(ObjVer objVer, MFCheckOutStatus status, CancellationToken token = default(CancellationToken)) { // Sanity. if (null == objVer) throw new ArgumentNullException(nameof(objVer)); // Create the request. var request = new RestRequest($"/REST/objects/{objVer.Type}/{objVer.ID}/{objVer.Version}/checkedout"); request.AddJsonBody(status); // Make the request and get the response. var response = await this.MFWSClient.Put<ObjectVersion>(request, token) .ConfigureAwait(false); // Return the data. return response.Data; }
0
4. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultObjectOperations.cs
Source File: MFWSVaultObjectOperations.cs
public async Task<ObjectVersion> UndeleteObjectAsync(ObjID objId, CancellationToken token = default(CancellationToken)) { // Sanity. if (null == objId) throw new ArgumentNullException(nameof(objId)); // Create the request. var request = new RestRequest($"/REST/objects/{objId.Type}/{objId.ID}/deleted"); request.Method = Method.PUT; // Add the body. request.AddJsonBody(new PrimitiveType<bool>() { Value = false }); // Make the request and get the response. var response = await this.MFWSClient.Put<ObjectVersion>(request, token) .ConfigureAwait(false); // If success, returns 204. return response.Data; }
0
5. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultObjectOperations.cs
Source File: MFWSVaultObjectOperations.cs
public async Task<ObjectVersion> DeleteObjectAsync(ObjID objId, CancellationToken token = default(CancellationToken)) { // Sanity. if (null == objId) throw new ArgumentNullException(nameof(objId)); // Create the request. var request = new RestRequest($"/REST/objects/{objId.Type}/{objId.ID}/deleted"); request.Method = Method.PUT; // Add the body. request.AddJsonBody(new PrimitiveType<bool>() { Value = true }); // Make the request and get the response. var response = await this.MFWSClient.Put<ObjectVersion>(request, token) .ConfigureAwait(false); // If success, returns 204. return response.Data; }
0
6. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultObjectOperations.cs
Source File: MFWSVaultObjectOperations.cs
public async Task<ExtendedObjectVersion> AddToFavoritesAsync(ObjID objId, CancellationToken token = default(CancellationToken)) { // Sanity. if (null == objId) throw new ArgumentNullException(nameof(objId)); // Create the request. var request = new RestRequest("/REST/favorites"); request.AddJsonBody(objId); // Make the request and get the response. var response = await this.MFWSClient.Post<ExtendedObjectVersion>(request, token) .ConfigureAwait(false); // Return the data. return response.Data; }
0
7. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultObjectPropertyOperations.cs
Source File: MFWSVaultObjectPropertyOperations.cs
public async Task<PropertyValue[][]> GetPropertiesOfMultipleObjectsAsync(CancellationToken token, params ObjVer[] objVers) { // Sanity. if (null == objVers || objVers.Length == 0) return new PropertyValue[0][]; // Create the request. var request = new RestRequest("/REST/objects/properties"); // Add the body. request.AddJsonBody(objVers); // Make the request and get the response. var response = await this.MFWSClient.Post<List<List<PropertyValue>>>(request, token) .ConfigureAwait(false); // Return the data. return response.Data?.Select(a => a.ToArray()).ToArray(); }
0
8. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSClient.Authentication.cs
Source File: MFWSClient.Authentication.cs
public async Task AuthenticateUsingCredentialsAsync(Authentication authentication, CancellationToken token = default(CancellationToken)) { // Clear any current tokens. this.ClearAuthenticationToken(); // Sanity. if (null == authentication) return; // Build the request to authenticate to the server. { var request = new RestRequest("/REST/server/authenticationtokens"); request.AddJsonBody(authentication); // Execute the request and store the response. var response = await this.Post<PrimitiveType<string>>(request, token) .ConfigureAwait(false); // Save the authentication token. this.AuthenticationToken = response?.Data?.Value; } }
0
9. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultObjectOperations.cs
Source File: MFWSVaultObjectOperations.cs
public async Task<ObjectVersion> CreateNewObjectAsync(int objectTypeId, ObjectCreationInfo creationInfo, CancellationToken token = default(CancellationToken)) { // Sanity. if (null == creationInfo) throw new ArgumentNullException(); if (objectTypeId < 0) throw new ArgumentException("The object type id cannot be less than zero"); creationInfo.Files = creationInfo.Files ?? new UploadInfo[0]; // Remove the extension from the item title if it exists. foreach (var item in creationInfo.Files) { // Sanity. if (string.IsNullOrWhiteSpace(item.Title) || string.IsNullOrWhiteSpace(item.Extension)) continue; // If the title ends with the extension then remove it. if (true == item.Title?.EndsWith("." + item.Extension)) { // Note the +1 is because we want to remove the dot as well. item.Title = item.Title.Substring(0, item.Title.Length - (item.Extension.Length + 1)); } } // Create the request. var request = new RestRequest($"/REST/objects/{objectTypeId}"); request.AddJsonBody(creationInfo); // Make the request and get the response. var response = await this.MFWSClient.Post<ObjectVersion>(request, token) .ConfigureAwait(false); // Return the data. return response.Data; }
0
10. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultObjectOperations.cs
Source File: MFWSVaultObjectOperations.cs
public async Task<ObjectVersion> SetCheckoutStatusAsync(ObjID objId, MFCheckOutStatus status, int? version = null, CancellationToken token = default(CancellationToken)) { // Sanity. if (null == objId) throw new ArgumentNullException(nameof(objId)); // Create the request. var request = new RestRequest($"/REST/objects/{objId.Type}/{objId.ID}/{version?.ToString() ?? "latest"}/checkedout"); request.AddJsonBody(new PrimitiveType<MFCheckOutStatus>() { Value = status }); // Make the request and get the response. var response = await this.MFWSClient.Put<ObjectVersion>(request, token) .ConfigureAwait(false); // Return the data. return response.Data; }
0
11. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultObjectPropertyOperations.cs
Source File: MFWSVaultObjectPropertyOperations.cs
public async Task<ExtendedObjectVersion> SetPropertyAsync(int objectTypeId, int objectId, PropertyValue newPropertyValue, int? version = null, CancellationToken token = default(CancellationToken)) { // Sanity. if (objectTypeId < 0) throw new ArgumentException("The object type id cannot be less than zero"); if (objectId <= 0) throw new ArgumentException("The object id cannot be less than or equal to zero"); if (null == newPropertyValue) throw new ArgumentNullException(nameof(newPropertyValue)); if (newPropertyValue.PropertyDef < 0) throw new ArgumentException("The property definition is invalid", nameof(newPropertyValue)); // Create the request. var request = new RestRequest($"/REST/objects/{objectTypeId}/{objectId}/{version?.ToString() ?? "latest"}/properties/{newPropertyValue.PropertyDef}"); request.Method = Method.PUT; // Set the request body. request.AddJsonBody(newPropertyValue); // Make the request and get the response. var response = await this.MFWSClient.Put<ExtendedObjectVersion>(request, token) .ConfigureAwait(false); // Return the data. return response.Data; }
0
12. Example
Project: Ombi
Source File: PlexApi.cs
Source File: PlexApi.cs
public PlexAuthentication SignIn(string username, string password) { var userModel = new PlexUserRequest { user = new UserRequest { password = password, login = username } }; var request = new RestRequest { Method = Method.POST }; AddHeaders(ref request, false); request.AddJsonBody(userModel); var obj = Api.Execute<PlexAuthentication> (request, new Uri(SignInUri)); return obj; }
0
13. Example
Project: Ombi
Source File: SonarrApi.cs
Source File: SonarrApi.cs
public SonarrEpisode UpdateEpisode(SonarrEpisode episodeInfo, string apiKey, Uri baseUrl) { var request = new RestRequest { Resource = "/api/Episode", Method = Method.PUT }; request.AddHeader("X-Api-Key", apiKey); request.AddJsonBody(episodeInfo); try { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling UpdateEpisode for Sonarr, Retrying {0}", timespan)); return policy.Execute(() => Api.ExecuteJson<SonarrEpisode>(request, baseUrl)); } catch (Exception e) { Log.Error(e, "There has been an API exception when put the Sonarr UpdateEpisode"); return null; } }
0
14. Example
Project: Ombi
Source File: SonarrApi.cs
Source File: SonarrApi.cs
public SonarrEpisodes UpdateEpisode(SonarrEpisodes episodeInfo, string apiKey, Uri baseUrl) { var request = new RestRequest { Resource = "/api/Episode", Method = Method.PUT }; request.AddHeader("X-Api-Key", apiKey); request.AddJsonBody(episodeInfo); try { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling UpdateEpisode for Sonarr, Retrying {0}", timespan)); return policy.Execute(() => Api.ExecuteJson<SonarrEpisodes>(request, baseUrl)); } catch (Exception e) { Log.Error(e, "There has been an API exception when put the Sonarr UpdateEpisode"); return null; } }
0
15. Example
Project: Ombi
Source File: SonarrApi.cs
Source File: SonarrApi.cs
public SonarrAddEpisodeResult SearchForEpisodes(int[] episodeIds, string apiKey, Uri baseUrl) { var request = new RestRequest { Resource = "/api/Command", Method = Method.POST }; request.AddHeader("X-Api-Key", apiKey); var body = new SonarrAddEpisodeBody { name = "EpisodeSearch", episodeIds = episodeIds }; request.AddJsonBody(body); try { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling SearchForEpisodes for Sonarr, Retrying {0}", timespan)); return policy.Execute(() => Api.ExecuteJson<SonarrAddEpisodeResult>(request, baseUrl)); } catch (Exception e) { Log.Error(e, "There has been an API exception when put the Sonarr SearchForEpisodes"); return null; } }
0
16. Example
Project: Ombi
Source File: SonarrApi.cs
Source File: SonarrApi.cs
public Series UpdateSeries(Series series, string apiKey, Uri baseUrl) { var request = new RestRequest { Resource = "/api/Series", Method = Method.PUT }; request.AddHeader("X-Api-Key", apiKey); request.AddJsonBody(series); try { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling UpdateSeries for Sonarr, Retrying {0}", timespan)); return policy.Execute(() => Api.ExecuteJson<Series>(request, baseUrl)); } catch (Exception e) { Log.Error(e, "There has been an API exception when put the Sonarr UpdateSeries"); return null; } }
0
17. Example
Project: Ombi
Source File: SonarrApi.cs
Source File: SonarrApi.cs
public SonarrSeasonSearchResult SearchForSeason(int seriesId, int seasonNumber, string apiKey, Uri baseUrl) { var request = new RestRequest { Resource = "/api/Command", Method = Method.POST }; request.AddHeader("X-Api-Key", apiKey); var body = new SonarrSearchCommand { name = "SeasonSearch", seriesId = seriesId, seasonNumber = seasonNumber }; request.AddJsonBody(body); try { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling SearchForSeason for Sonarr, Retrying {0}", timespan)); return policy.Execute(() => Api.ExecuteJson<SonarrSeasonSearchResult>(request, baseUrl)); } catch (Exception e) { Log.Error(e, "There has been an API exception when put the Sonarr SearchForSeason"); return null; } }
0
18. Example
Project: Ombi
Source File: SonarrApi.cs
Source File: SonarrApi.cs
public SonarrSeriesSearchResult SearchForSeries(int seriesId, string apiKey, Uri baseUrl) { var request = new RestRequest { Resource = "/api/Command", Method = Method.POST }; request.AddHeader("X-Api-Key", apiKey); var body = new SonarrSearchCommand { name = "SeriesSearch", seriesId = seriesId }; request.AddJsonBody(body); try { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling SearchForSeries for Sonarr, Retrying {0}", timespan)); return policy.Execute(() => Api.ExecuteJson<SonarrSeriesSearchResult>(request, baseUrl)); } catch (Exception e) { Log.Error(e, "There has been an API exception when put the Sonarr SearchForSeries"); return null; } }
0
19. Example
Project: Ombi
Source File: DiscordApi.cs
Source File: DiscordApi.cs
public void SendMessage(string message, string webhookId, string webhookToken, string username = null) { var request = new RestRequest { Resource = "webhooks/{webhookId}/{webhookToken}", Method = Method.POST }; request.AddUrlSegment("webhookId", webhookId); request.AddUrlSegment("webhookToken", webhookToken); var body = new DiscordWebhookRequest { content = message, username = username }; request.AddJsonBody(body); request.AddHeader("Content-Type", "application/json"); Api.Execute(request, Endpoint); }
0
20. Example
Project: Ombi
Source File: SlackApi.cs
Source File: SlackApi.cs
public async Task<string> PushAsync(string team, string token, string service, SlackNotificationBody message) { var request = new RestRequest { Method = Method.POST, Resource = "/services/{team}/{service}/{token}" }; request.AddUrlSegment("team", team); request.AddUrlSegment("service", service); request.AddUrlSegment("token", token); request.AddJsonBody(message); var api = new ApiRequest(); return await Task.Run( () => { var result = api.Execute(request, new Uri("https://hooks.slack.com/")); return result.Content; }); }
0
21. Example
Project: Ombi
Source File: SonarrApi.cs
Source File: SonarrApi.cs
public SonarrAddSeries AddSeries(SonarrAddSeries series,string apiKey, Uri baseUrl) { var request = new RestRequest { Resource = "/api/Series?", Method = Method.POST }; Log.Debug("Sonarr API Options:"); Log.Debug(series.DumpJson()); request.AddHeader("X-Api-Key", apiKey); request.AddJsonBody(series); SonarrAddSeries result; try { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling AddSeries for Sonarr, Retrying {0}", timespan), new TimeSpan[] { TimeSpan.FromSeconds (2) }); result = policy.Execute(() => Api.ExecuteJson<SonarrAddSeries>(request, baseUrl)); } catch (JsonSerializationException jse) { Log.Error(jse); var error = Api.ExecuteJson<List<SonarrError>>(request, baseUrl); var messages = error?.Select(x => x.errorMessage).ToList(); messages?.ForEach(x => Log.Error(x)); result = new SonarrAddSeries { ErrorMessages = messages }; } return result; }
0
22. Example
Project: Ombi
Source File: SonarrApi.cs
Source File: SonarrApi.cs
public SonarrAddSeries AddSeriesNew(int tvdbId, string title, int qualityId, bool seasonFolders, str/n ..... /n //View Source file for more details /n }
0
23. Example
Project: bvcms
Source File: Misc.cs
Source File: Misc.cs
public string RestPostJson(string url, PythonDictionary headers, object obj, string user = null, string password = null) { var client = new RestClient(url); if (user?.Length > 0 && password?.Length > 0) client.Authenticator = new HttpBasicAuthenticator(user, password); var request = new RestRequest(Method.POST); request.JsonSerializer = new RestSharp.Serializers.Shared.JsonSerializer(); foreach (var kv in headers) request.AddHeader((string)kv.Key, (string)kv.Value); request.AddJsonBody(obj); var response = client.Execute(request); return response.Content; }
0
24. Example
Project: MFilesSamplesAndLibraries
Source File: MFWSVaultObjectFileOperations.cs
Source File: MFWSVaultObjectFileOperations.cs
public async Task<ExtendedObjectVersion> AddFilesAsync(int objectType, int objectId, int? objectVersion = null, CancellationToken token = default(CancellationToken), params FileInfo[] files) { // Sanity. if (null == files) throw new ArgumentNullException(nameof(files)); // Firstly, upload the temporary files. var uploadInfo = await this.UploadFilesAsync(token, files); // Remove the extension from the item title if it exists. foreach (var item in uploadInfo) { // Sanity. if (string.IsNullOrWhiteSpace(item.Title) || string.IsNullOrWhiteSpace(item.Extension)) continue; // If the title ends with the extension then remove it. if (true == item.Title?.EndsWith("." + item.Extension)) { // Note the +1 is because we want to remove the dot as well. item.Title = item.Title.Substring(0, item.Title.Length - (item.Extension.Length + 1)); } } // Create the version string to be used for the uri segment. var versionString = objectVersion?.ToString() ?? "latest"; // Build up the request. var request = new RestRequest($"/REST/objects/{objectType}/{objectId}/{versionString}/files/upload"); request.AddJsonBody(uploadInfo); // Execute the request. var response = await this.MFWSClient.Post<ExtendedObjectVersion>(request, token) .ConfigureAwait(false); // Return the content. return response?.Data; }
0
25. Example
Project: Lean
Source File: GDAXBrokerage.cs
Source File: GDAXBrokerage.cs
public override bool PlaceOrder(Order order) { LockStream(); var re/n ..... /n //View Source file for more details /n }
0
26. Example
Project: Ombi
Source File: DiscordApi.cs
Source File: DiscordApi.cs
public async Task SendMessageAsync(string message, string webhookId, string webhookToken, string username = null) { var request = new RestRequest { Resource = "webhooks/{webhookId}/{webhookToken}", Method = Method.POST }; request.AddUrlSegment("webhookId", webhookId); request.AddUrlSegment("webhookToken", webhookToken); var body = new DiscordWebhookRequest { content = message, username = username }; request.AddJsonBody(body); request.AddHeader("Content-Type", "application/json"); await Task.Run( () => { Api.Execute(request, Endpoint); }); }
0
27. Example
Project: Ombi
Source File: PushbulletApi.cs
Source File: PushbulletApi.cs
public async Task<PushbulletResponse> PushAsync(string accessToken, string title, string message, string deviceIdentifier = default(string)) { var request = new RestRequest { Method = Method.POST, }; request.AddHeader("Access-Token", accessToken); request.AddHeader("Content-Type", "application/json"); var push = new PushbulletPush { title = title, body = message, type = "note"}; if (!string.IsNullOrEmpty(deviceIdentifier)) { push.device_iden = deviceIdentifier; } request.AddJsonBody(push); var api = new ApiRequest(); return await Task.Run(() => api.ExecuteJson<PushbulletResponse>(request, new Uri("https://api.pushbullet.com/v2/pushes"))); }
0
28. Example
Project: Ombi
Source File: SonarrApi.cs
Source File: SonarrApi.cs
public SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string/n ..... /n //View Source file for more details /n }
0
29. Example
Project: Ombi
Source File: EmbyApi.cs
Source File: EmbyApi.cs
public EmbyUser LogIn(string username, string password, string apiKey, Uri baseUri) { var request = new RestRequest { Resource = "emby/users/authenticatebyname", Method = Method.POST }; var body = new { username, password = StringHasher.GetSha1Hash(password).ToLower(), passwordMd5 = StringHasher.CalcuateMd5Hash(password) }; request.AddJsonBody(body); request.AddHeader("X-Emby-Authorization", $"MediaBrowser Client=\"Ombi\", Device=\"Ombi\", DeviceId=\"{AssemblyHelper.GetProductVersion()}\", Version=\"{AssemblyHelper.GetAssemblyVersion()}\""); AddHeaders(request, apiKey); var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling LogInfor Emby, Retrying {0}", timespan), new[] { TimeSpan.FromSeconds (1) }); var obj = policy.Execute(() => Api.Execute(request, baseUri)); if (obj.StatusCode == HttpStatusCode.Unauthorized) { return null; } return JsonConvert.DeserializeObject<EmbyUserLogin>(obj.Content)?.User; }
0
30. Example
Project: Ombi
Source File: RadarrApi.cs
Source File: RadarrApi.cs
public RadarrAddMovie AddMovie(int tmdbId, string title, int year, int qualityId, string rootPath, s/n ..... /n //View Source file for more details /n }
0
31. Example
Project: Gallifrey
Source File: SimpleRestClient.cs
Source File: SimpleRestClient.cs
private IRestResponse Execute(Method method, HttpStatusCode expectedStatus, string path, object data = null) { var request = CreateRequest(method, path); if (data != null) { request.AddHeader("ContentType", "application/json"); request.AddJsonBody(data); } var response = client.Execute(request); AssertStatus(response, expectedStatus); return response; }
0
32. Example
Project: ACE
Source File: AccountController.cs
Source File: AccountController.cs
[HttpPost] public ActionResult Login(LoginModel model) { if (!ModelState.IsValid) return View(model); RestClient authClient = new RestClient(ConfigurationManager.AppSettings["Ace.Api"]); var authRequest = new RestRequest("/Account/Authenticate", Method.POST); authRequest.AddJsonBody(new { model.Username, model.Password }); var authResponse = authClient.Execute(authRequest); if (authResponse.StatusCode == HttpStatusCode.Unauthorized) { model.ErrorMessage = "Incorrect Username or Password"; return View(model); } else if (authResponse.StatusCode != HttpStatusCode.OK) { model.ErrorMessage = "Error connecting to API"; return View(model); } // else we got an OK response JObject response = JObject.Parse(authResponse.Content); var authToken = (string)response.SelectToken("authToken"); if (!string.IsNullOrWhiteSpace(authToken)) { JwtCookieManager.SetCookie(authToken); return RedirectToAction("Index", "Home", null); } return View(model); }
0
33. Example
Project: Popcorn
Source File: MovieService.cs
Source File: MovieService.cs
public async Task<(IEnumerable<MovieLightJson> movies, int nbMovies)> GetSimilarAsync(in/n ..... /n //View Source file for more details /n }
0
34. Example
Project: Drcom-Dialer
Source File: BmobAnalyze.cs
Source File: BmobAnalyze.cs
public static void SendAnalyze() { RestClient client = new RestClient("https://a/n ..... /n //View Source file for more details /n }
0
35. Example
Project: ACE
Source File: Program.cs
Source File: Program.cs
static void AuthenticatedLogin(string[] args) { string username; str/n ..... /n //View Source file for more details /n }