SignatureDoesNotMatch error when uploading a CSV to a Cognito user import job via pre-signed URL

Viewed 22

I have a server-side endpoint which starts a user import job with my Cognito user pool and returns a pre-signed URL to upload a CSV to for the job to actually process (as in the cognito documentation). The code runs successfully and returns a pre-signed URL, but when I try to upload a CSV file to it, I get an error. Doing it in the browser in javascript, with the code below, I get an empty 403 error:

        const response = await axios({
          method: "POST",
          url: urlRes.data.url,
          data: finalCsv,
          headers: {
            "Content-Type": "text/csv",
            "x-amz-server-side-encryption": "aws:kms",
          },
        });

I've also tried to upload via Postman to have more control, and regardless of the headers I do or don't include I'm getting the error:

<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>

I've also tried using PUT and GET requests instead of POST requests but got the same response.

I've tried looking around on SO, but the other answers I've seen have all been about S3 pre-signed URLs, which seem to work differently.

0 Answers
Related