Questions tagged [httpcontent]

79 questions
0
votes
0 answers

Post method call throwing internal server error

I am trying to call a POST method of Moosend API from my MVC application. The Post call is working fine from Postman but throwing error from controller. The Code goes as below: public async Task CreateEmailList() { try { …
Debaparna
  • 121
  • 4
0
votes
0 answers

How to write unit test for ReadAsStringAsync

I am trying to write unit tests for the following code: m_Client.SendAsync(request).ContinueWith(responseTask => { HttpResponseMessage response = responseTask.Result; try { string str =…
walruz
  • 1,135
  • 1
  • 13
  • 33
0
votes
1 answer

Mock HttpClient.SendAsync to return response with Content not null

I'm trying to mock var response = await httpClient.SendAsync(request, CancellationToken.None); but my response.Content is always null. My mock looks like... var httpResponseMessage = new…
Robert Green MBA
  • 1,834
  • 1
  • 22
  • 45
0
votes
0 answers

Problem with Post Request c# got Empty Result

I'm trying to make a simple translator for chinese website using DeepL Traslator, got the data from Live http header thank in advance --- thank in advance ---- thank in advance thank in advance --- thank in advance --- thank in advance thank in…
0
votes
0 answers

How to add CRC32 hash to the data returned as ByteRangeStreamContent?

I receive request to receive file content from WebApi. The request can also contain range header and so for that I use ByteRangeStreamContent to generate the content and then finally send this content as HttpResponse. This is the code that I use var…
Pawan Nogariya
  • 8,330
  • 12
  • 52
  • 105
0
votes
1 answer

How to generate Body Parameters/ Sample Request for Web API Help Page while having access to raw request body

I need help populating the Body Parameters for the documentation of this endpoint. It shows as empty: I realize that the reason this is happening is because I am currently reading the request body and then converting the information to…
Brandon Lumsden
  • 171
  • 1
  • 1
  • 6
0
votes
1 answer

C#.NET Web API 2, How can I extract a certain text from a website using the HttpContent on a HTTPGET async method?

I am new to Web and part of my Web API 2 training is to create an API controller that uses an HttpClient and an HttpContent to read entire website and from that to return only a specific portion to a text. When I call that website, it comes back to…
Sotiris
  • 1
  • 1
0
votes
0 answers

JObject.Parse returns two {{ instead of one { in beginning and end

I'm using JObject.Parse and it's not a valid json as it has two {{ in the beginning and two }} at the end instead of only one of each. Tried catching exception but didn't hit the exception of my try catch. If I remove the extra { in the beginning…
JoBo
  • 235
  • 4
  • 17
0
votes
1 answer

Safely using a StreamReader with HttpContent.ReadAsStreamAsync() without closing the underlying stream

I have multiple Attribute classes which need to access the data in an HttpContent (which is in an HttpActionContext's HttpRequstMessage) but I am having issues deciding on the best way to do it. I considered using the ReadAsStringAsync method on the…
Aaron T
  • 1,092
  • 2
  • 10
  • 25
0
votes
1 answer

localhost route not working should be returning JSON back when locating to URL

My fellow programmers, I basically have this async Get() method which is reading Json data successfully, but when locating to route -> localhost:59185/api/encompass/data I receive a message: No HTTP resource was found that matches the request URL…
fay
  • 13
  • 9
0
votes
0 answers

why httpcontent readasstringasync throws cancelled exception

I'm not sure how much of my code here is relevant in figuring out the problem so I'll start from the top. I use Injection to create an azure web job program and it looks like this: static void Main() { try { //CompositionRoot code…
Bagzli
  • 6,254
  • 17
  • 80
  • 163
0
votes
0 answers

Method HttpContent.ReadAsStringAsync() returns invalid html code. How it can be?

Here is some code,to request html-code from url. var currentUrl = "https://www.google.com"; HttpClient client = new HttpClient(); System.Diagnostics.Process.Start(currentUrl); //here i open a browser with same URL, var response = await…
Mister Crabs
  • 41
  • 1
  • 5
0
votes
1 answer

how to send Content-Disposition: form-data; name="name" in correct way when call post api from C# to avoid statuserror 500

public async Task PostFrom(string baseAddress, string url, string requestbody) { T obj = default(T); //Create the Uri string string request = baseAddress + url; WriteLog(request + " : " + "start"); try { …
0
votes
1 answer

await HttpContent.CopyToAsync() results in empty target stream

I'm trying (and failing) to get the actual JSON string from a Request.HttpContent object. Here's what I'm doing: private async Task GetRequestBodyAsString(HttpContent content) { string result; using (var streamCopy = new…
Peter Huppertz
  • 361
  • 3
  • 7
0
votes
3 answers

Can not deserialize HttpContent from POST request

I am trying to send a POST request to a server.The request gets into the Middleware's Invoke method. However the Content is always null, no matter the type of the object. Sender public async Task RunTestAsync(string request) { try { …
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152