SES CreateImportJob CSV AttributesData JSON object

0

When creating CSV file to upload to s3, docs say:

The AttributesData is a JSON field where you can put any metadata about our contact. It must be a valid JSON object

OK, I've got attributes lastName and firstName. so the valid JSON object must be:

{ "firstName":"John","lastName":"Doe"}

Now go my assumptions:

This object is being put to CSV file, which is - surprize-suprize - COMMA separated values. so it counts as JSON object

{ "firstName":"John"

which is, of course, invalid JSON object and somewhere inside AWS error happens at this moment, but I get no errors, only the response with metadata and JobId.

After attributesData in CSV goes topicPreferences.MyTopic, which AWS counts as

"lastName":"Doe"}

Of course, this is incorrect, this topic doesn't exist in my list.

I've tested it with only firstName to avoid commas in JSON object - CreateImportJob now worked as expected, I've got a subscriber with:

"AttributesData": "{\"firstName\":\"John\"}",

So, question is: can I somehow add multiple attributes to AttributesData with exported to s3 bucket CSV file? Or AWS CreateImportJob can't afford this simple case?

asked 10 months ago266 views
1 Answer
0

When you create a CSV file for upload to S3, you need to ensure that the JSON object is represented correctly as a string. To represent a JSON object in a CSV file as a string, use double quotes around the entire object.

For example, if you have the attributes firstName and lastName, the correct representation in the CSV file would be:

"AttributesData" "{\"firstName\":\"John\",\"lastName\":\"Doe\"}"

Here, the AttributesData field contains a JSON object as a string, and it is enclosed in double quotes to ensure that commas within the JSON object do not interfere with the CSV format.

For example, if you have the attributes firstName and lastName, the correct representation in the CSV file would be:

"AttributesData" : "{\"firstName\":\"John\",\"lastName\":\"Doe\"}"

Here, the AttributesData field contains a JSON object as a string, and it is enclosed in double quotes to ensure that commas within the JSON object do not interfere with the CSV format.

If you want to add multiple attributes to the AttributesData field, you can include all of them within the JSON object. For example:

"AttributesData" : "{\"firstName\":\"John\",\"lastName\":\"Doe\",\"age\":30,\"email\":\"john.doe@example.com\"}"

In this case, the AttributesData field contains multiple attributes: firstName, lastName, age, and email.

If you experienced incorrect behaviour when trying to export topicPreferences.MyTopic, it is possible that the CSV file formatting or data mapping was problematic. In the AttributesData field, double-check your CSV file's structure and content to ensure it is correctly formatted with valid JSON objects.

Having shared the above, to answer your question and assist you in right direction, we require details that are non-public information. Please open a support case with AWS using the following link https://console.aws.amazon.com/support/home#/case/create

AWS
SUPPORT ENGINEER
answered 10 months ago
  • No, it doesn't work. I tried all these possibilities. CSV file content was:

    First I made as you stated: stringified JSON object emailAddress,unsubscribeAll,attributesData,topicPreferences.my-topic my@e.mail,false,"{\"firstName\":\"John\",\"lastName\":\"Doe\"}",OPT_IN -- it didn't work

    Then I tried stringified JSON object without commas: emailAddress,unsubscribeAll,attributesData,topicPreferences.my-topic my@e.mail,false,"{\"firstName\":\"John\"}",OPT_IN -- it also didn't work

    This is what I started with: valid non-stringified JSON object emailAddress,unsubscribeAll,attributesData,topicPreferences.my-topic my@e.mail,false,{"firstName":"John","lastName":"Doe"},OPT_IN -- didn't work because of comma inside JSON

    And finally, but I wrote about it yesterday emailAddress,unsubscribeAll,attributesData,topicPreferences.my-topic my@e.mail,false,{"firstName":"John"},OPT_IN -- the only CSV file content that worked because there's no commas and it really is valid non-stringified JSON object

    any more suggestions?

    P.S. as I understood, CSV parser doesn't care about escaped chars. it sees comma - it makes it the end of the "cell"

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions