title: Service: AmazonSQS; Status Code: 403; Error Code: SignatureDoesNotMatch; SQS
body: <p>i am running my simple class on ec2 to create or send messages on SQS. But this giving me Service: AmazonSQS; Status Code: 403; Error Code: SignatureDoesNotMatch;  </p>
  
  <p>i'm attaching my code and the error below:-</p>
  
  <pre><code>private AWSSimpleQueueServiceUtil() {
      try {
          this.simpleQueue = "demo-Photo-Queue";
          //this.sqs = (AmazonSQS) AmazonSQSClientBuilder.standard().build();
          //this.sqs.setEndpoint("https://a4b.us-east-1.amazonaws.com");
          this.sqs = (AmazonSQS)  AmazonSQSClientBuilder.standard()
          .withRegion(Regions.US_EAST_1)
          .build();
  
      } catch (Exception e) {
          System.out.println("exception while creating awss3client : " + e);
      }
  }
  
  public static AWSSimpleQueueServiceUtil getInstance() {
      return awssqsUtil;
  }
  
  public AmazonSQS getAWSSQSClient() {
      return awssqsUtil.sqs;
  }
  
  public String getQueueName() {
      return awssqsUtil.simpleQueue;
  }
  
  /**
   * Creates a queue in your region and returns the url of the queue
   * 
   * @param queueName
   * @return
   */
  public String createQueue(String queueName) {
      CreateQueueRequest createQueueRequest = new CreateQueueRequest(queueName);
      String queueUrl = this.sqs.createQueue(createQueueRequest).getQueueUrl();
      return queueUrl;
  }
  
  /**
   * returns the queueurl for for sqs queue if you pass in a name
   * 
   * @param queueName
   * @return
   */
  public String getQueueUrl(String queueName) {
      GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(queueName);
      return this.sqs.getQueueUrl(getQueueUrlRequest).getQueueUrl();
  }
  
  /**
   * send a single message to your sqs queue
   * 
   * @param queueUrl
   * @param message
   */
  public void sendMessageToQueue(String queueUrl, String message) {
      SendMessageResult messageResult = this.sqs.sendMessage(new SendMessageRequest(queueUrl, message));
      System.out.println(messageResult.toString());
      System.out.println("send successfully");
  }
  
  public static void main(String[] args) throws UnsupportedEncodingException {
      //String thePath = "https://sqs.us-east-1.amazonaws.com/685308457175/demo-Photo-Queue";
      String queueName = "myFisrtQueue";
      queueName = URLEncoder.encode(queueName, "UTF-8");
      System.out.println(queueName);
      AWSSimpleQueueServiceUtil.getInstance().createQueue("queueName");
  
  }
  </code></pre>
  
  <p>and following is the error I received :-</p>
  
  <blockquote>
    <p>(Service: AmazonSQS; Status Code: 403; Error Code: SignatureDoesNotMatch; Request ID: 20311998-3b24-5878-a1d6-4d5cdc182fa2)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1592)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1257)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1029)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:741)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:715)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:697)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:665)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:647)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:511)
        at com.amazonaws.services.sqs.AmazonSQSClient.doInvoke(AmazonSQSClient.java:1740)
        at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:1716)
        at com.amazonaws.services.sqs.AmazonSQSClient.executeSendMessage(AmazonSQSClient.java:1503)
        at com.amazonaws.services.sqs.AmazonSQSClient.sendMessage(AmazonSQSClient.java:1480)
        at com.SQSDemojava.demo.AWSSimpleQueueServiceUtil.sendMessageToQueue(AWSSimpleQueueServiceUtil.java:87)
        at com.SQSDemojava.demo.AWSSimpleQueueServiceUtil.main(AWSSimpleQueueServiceUtil.java:120)
    myFisrtQueue</p>
  </blockquote>