//snippet-sourcedescription:[SubscribeHTTPS.java demonstrates how to send a confirmation message to a URL.]
//snippet-keyword:[Java]
//snippet-sourcesyntax:[java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon Simple Notification Service]
//snippet-service:[sns]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[2019-07-20]
//snippet-sourceauthor:[jschwarzwalder AWS]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
//snippet-start:[sns.java2.SubscribeHTTPS.complete]

package com.example.sns;
//snippet-start:[sns.java2.SubscribeHTTPS.import]

import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sns.SnsClient;
import software.amazon.awssdk.services.sns.model.SubscribeRequest;
import software.amazon.awssdk.services.sns.model.SubscribeResponse;
//snippet-end:[sns.java2.SubscribeHTTPS.import]

public class SubscribeHTTPS {

    public static void main(String[] args) {
        final String USAGE = "\n" +
                "SubscribeHTTPS - send confirmation message to a url endpoint.\n" +
                "Usage: SubscribeHTTPS <topicArn> <url>\n\n" +
                "Where:\n" +
                "  topicArn - the arn of the topic to subscribe.\n\n" +
                "  url - https endpoint to subscribe.\n\n";

        if (args.length < 2) {
            System.out.println(USAGE);
            System.exit(1);
        }

        //snippet-start:[sns.java2.SubscribeHTTPS.main]
        String topicArn = args[0];
        String url = args[1];

        SnsClient snsClient = SnsClient.builder().region(Region.US_EAST_1).build();

        SubscribeRequest request = SubscribeRequest.builder()
                .protocol("https")
                .endpoint(url)
                .returnSubscriptionArn(true)
                .topicArn(topicArn)
                .build();

        SubscribeResponse result = snsClient.subscribe(request);

        System.out.println("Subscription ARN: " + result.subscriptionArn() + "\n\n Status was " + result.sdkHttpResponse().statusCode());
        //snippet-end:[sns.java2.SubscribeHTTPS.main]
    }
}
//snippet-end:[sns.java2.SubscribeHTTPS.complete]
@@ -365,22 +365,16 @@
 or:%5B
-j
 sc
-hwarzwalder
+macdon
  AWS
@@ -398,18 +398,18 @@
  2010-20
-19
+20
  Amazon.
@@ -1038,16 +1038,17 @@
 le.sns;%0A
+%0A
 //snippe
@@ -1089,17 +1089,16 @@
 import%5D%0A
-%0A
 import s
@@ -1189,16 +1189,79 @@
 Client;%0A
+import software.amazon.awssdk.services.sns.model.SnsException;%0A
 import s
@@ -1864,17 +1864,16 @@
 %0A       
- 
 if (args
@@ -1965,16 +1965,17 @@
      %7D%0A%0A
+%0A
         
@@ -2159,14 +2159,14 @@
 .US_
+W
 E
-A
 ST_
-1
+2
 ).bu
@@ -2165,32 +2165,50 @@
 ST_2).build();%0A%0A
+        try %7B%0A    
         Subscrib
@@ -2284,17 +2284,16 @@
 ol(%22http
-s
 %22)%0A     
@@ -2426,32 +2426,36 @@
 ild();%0A%0A        
+    
 SubscribeRespons
@@ -2495,17 +2495,20 @@
 quest);%0A
-%0A
+    
         
@@ -2637,16 +2637,160 @@
 ode());%0A
+%0A        %7D catch (SnsException e) %7B%0A            System.err.println(e.awsErrorDetails().errorMessage());%0A            System.exit(1);%0A         %7D%0A%0A
         
@@ -2872,28 +2872,29 @@
 va2.SubscribeHTTPS.complete%5D
+%0A

Update SubscribeHTTPS.java