@@ -31,7 +31,7 @@ static async Task Execute()
3131 Console . WriteLine ( msg . Serialize ( ) ) ;
3232 Console . WriteLine ( response . StatusCode ) ;
3333 Console . WriteLine ( response . Headers ) ;
34- Console . WriteLine ( "\n \n Press any key to continue." ) ;
34+ Console . WriteLine ( "\n \n Press <Enter> to continue." ) ;
3535 Console . ReadLine ( ) ;
3636
3737 // Send a Single Email using the Mail Helper with convenience methods and initialized SendGridMessage object
@@ -48,7 +48,7 @@ static async Task Execute()
4848 Console . WriteLine ( msg . Serialize ( ) ) ;
4949 Console . WriteLine ( response . StatusCode ) ;
5050 Console . WriteLine ( response . Headers ) ;
51- Console . WriteLine ( "\n \n Press any key to continue." ) ;
51+ Console . WriteLine ( "\n \n Press <Enter> to continue." ) ;
5252 Console . ReadLine ( ) ;
5353
5454 // Send a Single Email using the Mail Helper, entirely with convenience methods
@@ -63,7 +63,7 @@ static async Task Execute()
6363 Console . WriteLine ( msg . Serialize ( ) ) ;
6464 Console . WriteLine ( response . StatusCode ) ;
6565 Console . WriteLine ( response . Headers ) ;
66- Console . WriteLine ( "\n \n Press any key to continue." ) ;
66+ Console . WriteLine ( "\n \n Press <Enter> to continue." ) ;
6767 Console . ReadLine ( ) ;
6868
6969 // Send a Single Email Without the Mail Helper
@@ -94,7 +94,7 @@ static async Task Execute()
9494 urlPath : "mail/send" ) ;
9595 Console . WriteLine ( response . StatusCode ) ;
9696 Console . WriteLine ( response . Headers ) ;
97- Console . WriteLine ( "\n \n Press any key to continue." ) ;
97+ Console . WriteLine ( "\n \n Press <Enter> to continue." ) ;
9898 Console . ReadLine ( ) ;
9999
100100 // GET Collection
@@ -107,7 +107,7 @@ static async Task Execute()
107107 Console . WriteLine ( response . StatusCode ) ;
108108 Console . WriteLine ( response . Body . ReadAsStringAsync ( ) . Result ) ;
109109 Console . WriteLine ( response . Headers ) ;
110- Console . WriteLine ( "\n \n Press any key to continue to POST." ) ;
110+ Console . WriteLine ( "\n \n Press <Enter> to continue to POST." ) ;
111111 Console . ReadLine ( ) ;
112112
113113 // POST
@@ -121,45 +121,50 @@ static async Task Execute()
121121 urlPath : "asm/groups" ,
122122 requestBody : json . ToString ( ) ) ;
123123 var ds_response = JsonConvert . DeserializeObject < Dictionary < string , dynamic > > ( response . Body . ReadAsStringAsync ( ) . Result ) ;
124- string group_id = ds_response [ "id" ] . ToString ( ) ;
125124 Console . WriteLine ( response . StatusCode ) ;
126125 Console . WriteLine ( response . Body . ReadAsStringAsync ( ) . Result ) ;
127126 Console . WriteLine ( response . Headers ) ;
128- Console . WriteLine ( "\n \n Press any key to continue to GET single." ) ;
127+ Console . WriteLine ( "\n \n Press <Enter> to continue to GET single." ) ;
129128 Console . ReadLine ( ) ;
130129
131- // GET Single
132- response = await client . RequestAsync ( method : SendGridClient . Method . GET ,
133- urlPath : string . Format ( "asm/groups/{0}" , group_id ) ) ;
134- Console . WriteLine ( response . StatusCode ) ;
135- Console . WriteLine ( response . Body . ReadAsStringAsync ( ) . Result ) ;
136- Console . WriteLine ( response . Headers ) ;
137- Console . WriteLine ( "\n \n Press any key to continue to PATCH." ) ;
138- Console . ReadLine ( ) ;
139-
140- // PATCH
141- requestBody = @"{
142- 'name': 'Cool Magic Products'
143- }" ;
144- json = JsonConvert . DeserializeObject < object > ( requestBody ) ;
145-
146- response = await client . RequestAsync ( method : SendGridClient . Method . PATCH ,
147- urlPath : string . Format ( "asm/groups/{0}" , group_id ) ,
148- requestBody : json . ToString ( ) ) ;
149- Console . WriteLine ( response . StatusCode ) ;
150- Console . WriteLine ( response . Body . ReadAsStringAsync ( ) . Result ) ;
151- Console . WriteLine ( response . Headers . ToString ( ) ) ;
152-
153- Console . WriteLine ( "\n \n Press any key to continue to PUT." ) ;
154- Console . ReadLine ( ) ;
155-
156- // DELETE
157- response = await client . RequestAsync ( method : SendGridClient . Method . DELETE ,
158- urlPath : string . Format ( "asm/groups/{0}" , group_id ) ) ;
159- Console . WriteLine ( response . StatusCode ) ;
160- Console . WriteLine ( response . Headers . ToString ( ) ) ;
161- Console . WriteLine ( "\n \n Press any key to DELETE and exit." ) ;
162- Console . ReadLine ( ) ;
130+ if ( ds_response != null && ds_response . ContainsKey ( "id" ) )
131+ {
132+ string group_id = ds_response [ "id" ] . ToString ( ) ;
133+
134+
135+ // GET Single
136+ response = await client . RequestAsync ( method : SendGridClient . Method . GET ,
137+ urlPath : string . Format ( "asm/groups/{0}" , group_id ) ) ;
138+ Console . WriteLine ( response . StatusCode ) ;
139+ Console . WriteLine ( response . Body . ReadAsStringAsync ( ) . Result ) ;
140+ Console . WriteLine ( response . Headers ) ;
141+ Console . WriteLine ( "\n \n Press <Enter> to continue to PATCH." ) ;
142+ Console . ReadLine ( ) ;
143+
144+ // PATCH
145+ requestBody = @"{
146+ 'name': 'Cool Magic Products'
147+ }" ;
148+ json = JsonConvert . DeserializeObject < object > ( requestBody ) ;
149+
150+ response = await client . RequestAsync ( method : SendGridClient . Method . PATCH ,
151+ urlPath : string . Format ( "asm/groups/{0}" , group_id ) ,
152+ requestBody : json . ToString ( ) ) ;
153+ Console . WriteLine ( response . StatusCode ) ;
154+ Console . WriteLine ( response . Body . ReadAsStringAsync ( ) . Result ) ;
155+ Console . WriteLine ( response . Headers . ToString ( ) ) ;
156+
157+ Console . WriteLine ( "\n \n Press <Enter> to continue to PUT." ) ;
158+ Console . ReadLine ( ) ;
159+
160+ // DELETE
161+ response = await client . RequestAsync ( method : SendGridClient . Method . DELETE ,
162+ urlPath : string . Format ( "asm/groups/{0}" , group_id ) ) ;
163+ Console . WriteLine ( response . StatusCode ) ;
164+ Console . WriteLine ( response . Headers . ToString ( ) ) ;
165+ Console . WriteLine ( "\n \n Press <Enter> to DELETE and exit." ) ;
166+ Console . ReadLine ( ) ;
167+ }
163168 }
164169 }
165170}
0 commit comments