Questions tagged [httpresponsemessage]

HttpResponseMessage refers to the C# public class that represents an HTTP response message including the status code and data. Use this tag for questions related to the public class.

HttpResponseMessage refers to the C# public class that represents an HTTP response message including the status code and data. Use this tag for questions related to the public class.

168 questions
0
votes
2 answers

Xamarin__HttpClient__HttpResponseMessage-Content --- Getting HTML instead of JSON

HttpClient myClient = new HttpClient(); myClient.BaseAddress = new Uri(URL); Base address already specified on client it's URL. var encodedObject = JsonConvert.SerializeObject(Obj); myClient.DefaultRequestHeaders.Accept.Add(new…
0
votes
0 answers

Http.HttpRequestException to vagrant host

I have REST API server on my vagrant machine. And I write client for it on c# (VS2015). Have same code: using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(_server); client.DefaultRequestHeaders.Accept.Clear(); …
derrs
  • 1
  • 3
0
votes
1 answer

Pass data with an image using web api

I need to pass an image within a json response. Here's my controller: public IHttpActionResult GetStudents() { var data = db.Students.ToList(); return Ok(data); } That code obviously returns all the data for each student and…
0
votes
2 answers

Controller returning HttpResponseMessage not setting content type correctly

I have the following code in a controller to return a stream which is an Excel File to download on the client side: HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); MemoryStream memStream =…
Simon Nicholls
  • 635
  • 1
  • 9
  • 31
0
votes
2 answers

HttpResponseMessage.Content.Header ignoring charset setting in meta tag in html source

I have just posted this question, which answer came right away. It, in turn, creates the following new question: If my understanding is correct, the StreamContent object, from HttpResponseMessage, is created upon making an HTTP request via…
Veverke
  • 9,208
  • 4
  • 51
  • 95
0
votes
0 answers

How to read HttpResponseMessage in IOS from web API?

We have asp.net Web API developed. In Web API controllers there are the Filters which generating HttpResponseMessage as response. These API's are consuming by IOS device application. All actions in API are returning HttpResponseMessage. If Filter…
Red Swan
  • 15,157
  • 43
  • 156
  • 238
-1
votes
1 answer

How to read http headers and obtain cookies from HttpResponseMessage using HttpClient

How can I get cookies from the HttpResponseMessage? I'm getting an Index out of bound exception when executing following code. Not sure where the problem is: using System; using System.Linq; using System.Net.Http; using System.Threading; using…
Dan
  • 11,077
  • 20
  • 84
  • 119
-1
votes
1 answer

I want to return a table and the number of rows present in the table as a response

I have to send the noOfRecords variable in the response. public HttpResponseMessage GetWareHouses(int pageNumber, int noofRows) { var result = myModelObject.SelectTableData(pageNumber, noofRows); int numberOfRec = result.Count; /*I need to send…
-1
votes
1 answer

HttpRequestMessage.CreateResponse threw StackOverflowException

I've a function app. I wrote a unit test project(xunit) to test my function app code. In unit test method I'm calling Run method of my function app. When request is 'Get' my function app returns a simple json object. While this is working fine in my…
-1
votes
1 answer

Error while returning HttpResponseMessage in.NET core

I have a simple API gateway controller which returns an IActionResult. The issue is I am not able to read the body of the response. If I comment out the using block in ExecuteResultAsync it seems to work fine but there is not content/body. Not…
-1
votes
2 answers

Null message on hTTPResponse.Content.ReadAsStringAsync().Result after 1st foreach loop

I have issue with null result messages when calling a HttpClient getAsync within a foreach loop. I need to iterate with a list of objects for values to call an API via HttpClient. After the first loop, the HttpResponseMessage's result() comes up…
-1
votes
1 answer

HttpClient call keeps on waiting mode but works fine in Console App

Below is the code which works perfectly fine when i execute it on console application. The line var postResponse = await client.SendAsync(req); give the result when i run the code in console app. But when iam using this code in WebApi controller,…
Rpcoder
  • 271
  • 1
  • 3
  • 11
-1
votes
1 answer

Why typeof(HttpResponseMessage) is null?

We have our own tool to create documentation of our web api. It reads the /// comments and creates the documentation from them. But we have one weird issue with it: The expression typeof(HttpResponseMessage) weirdly evaluates to null. Why this…
Al Kepp
  • 5,831
  • 2
  • 28
  • 48
-1
votes
2 answers

Is there any HTTP response body in case of HTTP RESPONSE CODE = 400?

I'm getting 400 response code for an HTTP request. I want to read the response message in PHP. I'm reading response code like this: $options = array( 'http' => array( 'header' => "Content-type: application/json\r\n", …
DesiHacker
  • 108
  • 2
  • 15
-1
votes
1 answer

GetAsync gives AggregateException

HttpResponseMessage response = client.GetAsync("api/MOB_Vw_UsersAPI/GetMOB_Vw_Users?Uname=" + uname + "&Pass=" + pass).Result; When I run this part of code on Windows Phone emulator things going well and it works fine. However, when I…
1 2 3
11
12