Invalid Parameter: Topic Name Error when publishing to AWS SNS arn endpoint
<p>In Java, I am trying to publish a AWS SNS message to a specific ARN endpoint using the following code:</p>

<pre><code>import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.sns.AmazonSNS;
import com.amazonaws.services.sns.AmazonSNSClient;
import com.amazonaws.services.sns.model.PublishRequest;
import com.amazonaws.services.sns.model.PublishResult;

...

AmazonSNS snsClient = new AmazonSNSClient(new BasicAWSCredentials(System.getenv("AWS_KEY"), System.getenv("AWS_SECRET")));

snsClient.setRegion(Region.getRegion(Regions.US_EAST_1));

String message = "{\"APNS_SANDBOX\":\"{\\\"aps\\\":{\\\"type\\\":\\\"XXX\\\",\\\"email\\\":\\\"XXX@gmail.com\\\",\\\"alert\\\":\\\"some alert\\\"}}\"}";

PublishResult pr = snsClient.publish(new PublishRequest("arn:aws:sns:us-east-1:XXX:endpoint/APNS_SANDBOX/XXX/XXX-XXX-XXX-XXX", message));
</code></pre>

<p>I am consistently getting the following error message:</p>

<p><code>Invalid parameter: Topic Name (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: XXX</code></p>

<p>Any idea on this? </p>

<p>I can publish to the ARN endpoint with no issues from the SNS console and I have tried different variations of the message</p>