Click here to Skip to main content
15,914,070 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm getting StatusCode: 200, but it is not reflecting on server.

Following is my code:

XML
String gsPMUsername="abcde";
String gsPMPassword ="password";
String lourl = "/association/property/ 4332056/meter";
String lodata = "<meterPropertyAssociationList>
  <energyMeterAssociation>
    <meters>
      <meterId>11718108</meterId>
    </meters>
    <propertyRepresentation>
      <propertyRepresentationType>Whole Property</propertyRepresentationType>
    </propertyRepresentation>
  </energyMeterAssociation>
</meterPropertyAssociationList>";
HttpClient goclient = new HttpClient();
goclient.BaseAddress = new Uri("https://portfoliomanager.energystar.gov/ws/");
Byte[] lbbuffer = Encoding.ASCII.GetBytes(string.Concat(gsPMUsername, ":", gsPMPassword));

AuthenticationHeaderValue loAuthHeader = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(lbbuffer));

goclient.DefaultRequestHeaders.Authorization = loAuthHeader;

goclient.DefaultRequestHeaders.Accept.Add(new

MediaTypeWithQualityHeaderValue("application/xml"));

HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, lourl);

req.Content = new StringContent(lodata, Encoding.UTF8, "application/xml");

var response = goclient.SendAsync(req, HttpCompletionOption.ResponseContentRead).Result;



I'm getting following reponse:
VB
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Transfer-Encoding: chunked
  Connection: keep-alive
  Vary: Accept-Encoding
  Vary: Cookie
  X-UA-Compatible: IE=Edge,chrome=1
  Link: <http://www.energystar.gov/buildings/facility-owners-and-managers/existing-buildings/use-portfolio-manager>; rel="canonical",<http://www.energystar.gov/node/14475>; rel="shortlink"
  Cache-Control: public, max-age=0
  Date: Fri, 20 Feb 2015 12:19:07 GMT
  ETag: "1423570746-0"
  Server: nginx
  Content-Language: en
  Content-Type: text/html; charset=utf-8
  Expires: Sun, 19 Nov 1978 05:00:00 GMT
  Last-Modified: Fri, 20 Feb 2015 12:19:06 GMT
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900