dotnet-httpclient

HttpClient in Universal Windows app running on Windows 10 IOT Core throws Exception from HRESULT: 0x80072EFD

早过忘川 提交于 2019-12-10 17:40:11
问题 I´m using VS2015 to deploy a universal app to a Raspberry Pi 2 Model B running Windows 10 IOT Core (10.0.10240). Any usage of the HttpClient to call a WebService or retrieve some data like the following HttpClient client = new HttpClient(); var re = await client.GetAsync("http://somehost/api/values/5"); yields an Exception from HRESULT: 0x80072EFD. Capabilities Internet (Client) Internet (Client & Server) Private Networks (Client & Server) are set in the app manifest. Any suggestions? 回答1:

C# HttpClient: Why MediaTypeWithQualityHeaderValue?

帅比萌擦擦* 提交于 2019-12-10 17:18:42
问题 What is the purpose of the MediaTypeWithQualityHeaderValue parameter when attempting to set the "Content-Type" header property on a request? The MSDN documentation simply states: Represents a content-type header value with an additional quality. What specifically is meant by 'an additional quality'? 回答1: The purpose is to comply with the HTTP standard, which under section 3.9 defines quality values. You can read further about it in RFC 2616. Here is a link : http://www.w3.org/Protocols

HttpClient / HttpRequestMessage accept header parameters cannot have spaces

↘锁芯ラ 提交于 2019-12-10 17:07:58
问题 I'm dealing with an API that requires me to set the header application/json;masked=false in order to unmask some information. When setting the header using var request = new HttpRequestMessage() request.Headers.Add("Accept", "application/json;masked=false"); it appears as though a space is being added between the ; and masked making the output header application/json; masked=false . Unfortunately this API I'm working with appears to be checking only against the literal application/json;masked

HttpClient PCL Cookies Not Being Applied to Requests

筅森魡賤 提交于 2019-12-10 16:55:42
问题 I'm using .NET HttpClient for PCL (2.2.15) for a common library across Windows Phone 8, Windows 8, and .NET 4.5. However, I don't see cookies being applied to requests. I'm setting up the HttpClient and HttpClientHandler using the following code. HttpClient is a property on the wrapping class. CookieContainer = new CookieContainer(); var handler = new HttpClientHandler { AllowAutoRedirect = true, CookieContainer = CookieContainer, Credentials = client.CredentialCache, UseCookies = true,

How to Create a Issue into JIRA through REST api?

笑着哭i 提交于 2019-12-10 16:34:11
问题 I am sending the POST request to the JIRA with my json data for create a project, but I am unable to create a project into JIRA, I tried to see the error from the Fiddler and I got following error. I am using the C# and created console application for it. My JSON data which I am posting is following. { "fields": { "project": { "key": "JTL" }, "issuetype": { "name": "BUG" } } } Error Message is following: {"errorMessages":[],"errors":{"issuetype":"issue type is required"}} I am posting json

Why doesn't traffic using Xamarin's monotouch implementation of MobileServiceClient show up in Fidder/Charles

≡放荡痞女 提交于 2019-12-10 13:46:55
问题 This is probably the same question as: HTTP Traffic monitoring issue when using MonoTouch, HttpClient and Charles Proxy But I thought I would ask it from a Windows Azure Mobile Services Client perspective. When I configure my iOS device to point at either fiddler (on my windows box) or charles (on my mac) I can see all traffic from a browser or from an Xamarin app that uses WebRequest. However if I use either Microsoft.WindowsAzure.MobileServices.MobileServiceClient (which uses HttpClient) or

How can I verify a deadlock in my async to sync method and HttpClient.PostAsync calls?

风流意气都作罢 提交于 2019-12-10 12:03:15
问题 I'm having a deadlock in my program but I can't figure out why and how to fix it. Short version: An async to sync method locks waiting for an async call, which calls another, and so on until a HttpClient.PostAsync call. The http post call never happens, at least it doesn't arrives in the server (which I own too). No errors in the client. My main questions are at the end of this SO question. Thanks! Longer version: I know that it is very easy to come up with deadlocks and we must be careful. I

The request message was already sent. Cannot send the same request message multiple times

拜拜、爱过 提交于 2019-12-10 02:56:24
问题 Is there anything wrong with my code here? I keep getting this error: System.InvalidOperationException: The request message was already sent. Cannot send the same request message multiple times. My HttpRequestMessage is inside a Func so I figured I get a brand new request each time I pass in func(). public async Task<HttpResponseMessage> GetAsync(HttpRequestMessage request) { return await RequestAsync(() => request); } public async Task<HttpResponseMessage> RequestAsync(Func

Explicitly Set Content-Type Headers For Get Operation in HttpClient

时光总嘲笑我的痴心妄想 提交于 2019-12-09 14:25:49
问题 Is there a way in which I can explicitly set the Content-Type header values when performing a GET with HttpClient ? I realise this breaks 1.1 protocol, but I am working with a API that does not conform to it, and REQUIRES I set a Content-Type Header. I have tried this with to no avail... using (var httpClient = new HttpClient()) { var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "http://example.com"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type",

HttpClient and ReadAsAsync<T>() extension method

倾然丶 夕夏残阳落幕 提交于 2019-12-09 14:21:55
问题 So I'm starting up a new .Net 4.0 project and will be doing some work with a public API. I'm planning on using the Microsoft HttpClient class so I installed the latest stable version of the Microsoft.Net.Http NuGet package (version 2.2.13). I'm looking at some POC code that a coworker put together, also using a NuGet package for HttpClient and notice that there's code like this: HttpClient client = new HttpClient(); HttpResponseMessage response = client.GetAync("/uri").Result; DomainType