c# - Serialize and deserialize HttpRequestMessage objects -


Do anyone have the experience of serializing HTTPPequest message objects? Trying from Json.net and it works partially. That said, JsonConvert.DeserializeObject fails due to structure issues StringContent: Unable to find a constructor to use for "System.Net.Http.StringContent".

Here is a brief in case of use that I want to save

  var request = new HttpRequestMessage (web request) Later, issue it in case of temporary network issues or in the case of service non-availability. HttpMethod.POST, "http://www.something.com"); Request.Headers.Date = DateTimeOffset.UtcNow; Request.Headers.AcceptLanguage.Add (New System.Net.Http.Headers.StringWithQualityHeaderValue ("en-US")); Request.Content = new StringContent ("Hello World!"); Request.Content.Headers.Add ("X-something", "Cheese"); Var result = JsonConvert.SerializeObject (request, new JsonSerializer settings {TypeNameHandling = TypeNameHandling.Objects, TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full}); Var deserializeRequest = JsonConvert.DeserializeObject & lt; HttpRequestMessage & gt; (Results, New JsonSerializer Settings {TypeNameHandling = TypeNameHandling.Objects});  

I would recommend sorting those items for which you have implemented in your codebase Keep up.

One of the reasons for HttpRequestMessage is not try serializing it is the fact that it implements IDisposable, which means that it can hold the context of unmanaged resources.


http://www.something.com ") .SetMethod (" POST ") .SetStringContent (" My content ") .DefaultRequestSettings () // A benefit you can encapsulate some arguments in the builder // Use (HTTP://www.bbc.ac.st... message) = builder.bild (datetime.utcnioo)) / / Maybe the original request is issued to the date header Needs to be upgraded

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -