RestAssured - Saving id from response for use in another method
<p>Im using RestAssured to test our API. I created a POST method that will post a new piece of content. I capture the new id from the response in that same session and save it as a variable like so:</p>

<pre><code>public String myId;

public void postSomething (){
    Response myResponse = 
    given ().
    when().contentType(ContentType.JSON).
    body(testData).
    post(postUrl);

    myId = myResponse.then().contentType(ContentType.JSON).extract().path("result.id")}
</code></pre>

<p>The method works in that the new content is created and I can print out the newly created id of the content I just created.</p>

<p>The issue is that I need the id for my DELETE method that I use later on to clean up my test data. My delete method looks like this:</p>

<pre><code>public void deleteTestData () {
Response myResponse = 
given().
when().
delete(deleteUrl + myId); }
</code></pre>

<p>This doesn't work for me. So in my deleteTestData() method, I did a</p>

<pre><code>System.out.println(myId);
</code></pre>

<p>to see what the value was for myId, but it came back null. Please forgive my noobiness, but any help I can get to saving the Id from the post response to later use in my delete method is appreciated.     </p>