restsharp

.Net C# RESTSharp 10 Minute Timeout

删除回忆录丶 提交于 2021-01-28 19:02:02
问题 I have embedded a browser control into a .Net form and compiled it as a window's executable. The browser control is displaying our HTML5 image viewer. The application opens sockets so it can listen to "push" requests from various servers. This allows images to be pushed to individual user's desktops. When an incoming image push request comes in, the application calls a REST service using RESTSharp to generate a token for the viewer to use to display the image. As long as the requests are

Trouble including a file in multipart/form-data POST using RestSharp

ε祈祈猫儿з 提交于 2021-01-28 05:05:27
问题 I'm relatively new to web interactions with C# and I'm having some trouble making a POST request to upload a file using an API. The API only accepts the files as part of a multipart/form-data section in the body. At other's suggestions I've been trying to use RestSharp to do this, but I can't seem to get the file itself into the POST. Chunks of code derived from Postman suggested code - where the POST works. I've tried a few things. This chunk resulted in a POST going through with the correct

Call A Multi-Part Form Method Programmatically

南笙酒味 提交于 2021-01-20 11:32:34
问题 I have the following method in my WebApi [HttpPost] [Route("foo/bar")] [Consumes("multipart/form-data")] [DisableRequestSizeLimit] public async Task<IActionResult> FooBar([FromForm] Data data) The Data class looks like this public class Data { public string A { get; set; } public string[] B { get; set; } public string[] C { get; set; } public IFormFile File { get; set; } } I am struggling to work out how I can pass the values in the Data class into this method via C# code. I need to pass the

Call A Multi-Part Form Method Programmatically

◇◆丶佛笑我妖孽 提交于 2021-01-20 11:31:39
问题 I have the following method in my WebApi [HttpPost] [Route("foo/bar")] [Consumes("multipart/form-data")] [DisableRequestSizeLimit] public async Task<IActionResult> FooBar([FromForm] Data data) The Data class looks like this public class Data { public string A { get; set; } public string[] B { get; set; } public string[] C { get; set; } public IFormFile File { get; set; } } I am struggling to work out how I can pass the values in the Data class into this method via C# code. I need to pass the

Call A Multi-Part Form Method Programmatically

大兔子大兔子 提交于 2021-01-20 11:30:20
问题 I have the following method in my WebApi [HttpPost] [Route("foo/bar")] [Consumes("multipart/form-data")] [DisableRequestSizeLimit] public async Task<IActionResult> FooBar([FromForm] Data data) The Data class looks like this public class Data { public string A { get; set; } public string[] B { get; set; } public string[] C { get; set; } public IFormFile File { get; set; } } I am struggling to work out how I can pass the values in the Data class into this method via C# code. I need to pass the

API is returning error when using RESTSHARP

帅比萌擦擦* 提交于 2020-07-18 09:03:23
问题 When use RestSharp to call an API I get this error: The underlying connection was closed: An unexpected error occurred on a send. I've verified that my client ID, secret, username, and password are correct. I'm able to do this without issues in PowerShell. public string GetTokenForBrightIdea() { RestClient restclient = new RestClient(_uri); RestRequest request = new RestRequest() { Method = Method.POST }; request.AddHeader("Accept", "application/json"); request.AddHeader("Content-Type",

How to parse JSON using RestSharp?

↘锁芯ラ 提交于 2020-07-18 04:03:52
问题 var client = new RestClient("http://10.0.2.2:50670/api"); var request = new RestRequest("Inventory", Method.GET); request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; }; // execute the request to return a list of InventoryItem RestResponse<JavaList<InventoryItem>> response = (RestResponse<JavaList<InventoryItem>>)client.Execute<JavaList<InventoryItem>>(request); The content returned is a JSON string, an array of objects. The following is a short excerpt of it: [{