title: HttpResponseMessage from HttpClient to User Defined Object C#
body: <p>I have seen similar questions asked but none that seem to help me with my issue so please bear with me.</p>
  
  <p>I have a WebAPI controller method that is defined as such:</p>
  
  <pre><code>[HttpPost]
  [Route("")]
  public HttpResponseMessage CreateMyObject(MyObjectRequest myObject)
  {
      MyObject o;
      try
      {
          o = _serviceFactory.GetInstance().CreateMyObject(myObject);
      }
      catch (Exception ex)
      {
          ex.WriteToLog();
          throw ApiHelper.CreateResponseException(HttpStatusCode.InternalServerError, ex);
      }
      var response = Request.CreateResponse(HttpStatusCode.Created, o);
      var uri = Url.Link("GetMyObjectById", new { myObjectId = o.MyObjectId.ToString() });
      response.Headers.Location = new Uri(uri);
      return response;
  }
  </code></pre>
  
  <p>Say, MyObject contains two properties, </p>
  
  <pre><code>public MyObject
  {
      public Guid MyObjectId;
      public string MyObjectName
  }
  </code></pre>
  
  <p>A client was written to call these controller methods in a WPF application.  Here is the client method that is being used:</p>
  
  <pre><code>public HttpResponseMessage CreateQuote(MyObjectRequest myObject)
  {
      var hashtable = new Hashtable
                  {
                      {"myObject", myObject}
                  };
  
      var task = GetResponse("", hashtable);
      var response = task.Result;
  
      return response;
  } 
  
  protected async Task&lt;HttpResponseMessage&gt; GetResponse(string path, Hashtable parameters)
  {
      var response = await GetAsync(BuildRequestUri(path, parameters)).ConfigureAwait(false);
      return response.IsSuccessStatusCode ? response : new HttpResponseMessage();
  }
  
  protected async Task&lt;HttpResponseMessage&gt; GetResponse(string path)
  {
      return await GetResponse(path, null);
  }
  </code></pre>
  
  <p>The controller and supporting client code was not written by me and was already in the system. I am just consuming this in the WPF application. Now, I am trying to call the controller method via the client in the application and get the MyObject from the response so that I can access the MyObjectId that has been created and set.  I have tried some of the other responses to similar questions but have not even seen some of the methods that are called on the response in order to get the information. Here is the first part of the call to the client that I have in the application:</p>
  
  <pre><code>var httpResponse = ApplicationService.CreateMyObject(myObjectRequest);
  </code></pre>
  
  <p>The application service simply injects the client into the constructor and allows me to call the CreateMyObject method. Is there any insight that can be given to me on how I should be getting the MyObject object out of the response?</p>