Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS error when try import contacts csv #1084

Closed
Kleinast opened this issue Feb 24, 2022 · 1 comment
Closed

AWS error when try import contacts csv #1084

Kleinast opened this issue Feb 24, 2022 · 1 comment

Comments

@Kleinast
Copy link

Issue Summary

I have "Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4" when try to import csv contact

Steps to Reproduce

  1. Ask for upload url
  2. curl to send contacts csv to given aws url

Code Snippet

try {
$request_body = [
            "file_type" => "csv",
            "field_mappings" => [
                '_rf2_T',
                '_rf0_T',
                '_rf1_T',
                null,
                null,
                '_rf6_T',
                null,
                '_rf8_T',
                '_rf9_T',
                'e1_T',
            ]
        ];

            $response = $this->sendGrid->client->marketing()->contacts()->imports()->put($request_body);
            dump(
                $response->statusCode(),
                $response->headers(),
                json_decode($response->body())
            );
        } catch (Exception $ex) {
            echo 'Caught exception: '.  $ex->getMessage();
        }

and after

curl --upload-file "contacts-upload-test.csv" "https://mc-contacts-import-upload-production.s3.us-west-2.amazonaws.com/***.csv\?*********" -H '{"header":"x-amz-server-side-encryption","value":"aws:kms"}'

Exception/Log

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidArgument</Code><Message>Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4.</Message><ArgumentName>Authorization</ArgumentName><ArgumentValue>null</ArgumentValue><RequestId>FMGG7740DC75MP5E</RequestId><HostId>ulXwz+ikcuVLWndOfuRqKmXzSd2b56U5nfwqLmytF4ViURwHcPjWC4ipQ31RuIyStf2KB/CgwYY=</HostId></Error>%

Technical details:

  • sendgrid-php version: 7.11.4
  • php version: 7.4.26
@Kleinast
Copy link
Author

I think I find the problem, just in https://docs.sendgrid.com/api-reference/contacts/import-contacts it say to call:
curl --upload-file "file/path.csv" "URL_GIVEN" -H 'HEADER_GIVEN'
But the given url given into double quote seem escape so it show me that error.
Also it's not really mention that the upload_uri response param give a json object that have to be transform from
{"header":"x-amz-server-side-encryption","value":"aws:kms"}
to
-H 'x-amz-server-side-encryption: aws:kms'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant