This is going to be an incredibly common pattern among API tests, so it might be worth extracting this to a method. Will leave to your discretion.