title: How do I use the response from a postasync call?
body: <p>I have a webApi set up that has a PostStudent method. The API call works fine and creates a new student in the DB, but I can't get it to return the value in the response body. I have tried returning Ok(newStudent) and Created("~/api/poststudent", newStudent) but neither of them have returned the newStudent value that I need.</p>
  
  <p>I have gone through all of the response and can't find the actual newStudent object. Is it there and I am just missing it or do I have a problem with my code?</p>
  
  <p>This is the PostStudent method from the API;</p>
  
  <pre><code>var newStudent = new Student
  {
    studentId = nextStudentId,
    studentFirstName = studentEntry.StudentFirstName,
    studentLastName = studentEntry.StudentLastName,
    studentDOB = studentEntry.StudentDob,
    studentEmergencyContactName = studentEntry.StudentEmergencyContactName,
    studentEmergencyContactNum = studentEntry.StudentEmergencyContactNum,
    ticketNumber = studentEntry.TicketNumber
  };
  
  db.Student.Add(newStudent);
  
  try
  {
    db.SaveChanges();
  }
  catch (DbUpdateException)
  {
    if (StudentExists(newStudent.studentId))
      return BadRequest("That student id already exists");
      throw;
  }
  return Ok(newStudent.studentId);
  // return Created("~/api/poststudent", newStudent);     
  }
  </code></pre>
  
  <p>This is where I call postasync and try to save the response body;</p>
  
  <pre><code>var response = client.PostAsync("api/poststudent", content);
  return response.Result.Content.ReadAsStringAsync().ToString();
  </code></pre>
  
  <p>And this is where I want to use the value;</p>
  
  <pre><code>var newStudentId = controller.PostStudent(studentFirstName, studentLastName, studentDob, ticketNumber);
  var url = "~/AddGuardian/AddGuardian/" + newStudentId;
  Response.Redirect(url);
  </code></pre>
  
  <p>I hope someone can help me. I never thought redirecting to another page would be so damn hard!</p>
  
  <p>Cheers.</p>