SES SendRawEmailCommand - TS2322: Type 'string' is not assignable to type 'Uint8Array'. #4761
-
I am using the aws-sdk v3 for typescript, and have included the SES client in my project like this I'm trying to follow the example syntax for SendRawEmailCommand here Using the exact syntax from the docs, I get an error saying Are the docs maybe incorrect? See snippet below where they are passing a string to the RawMessage.Data property, but the client-ses seems to require a Uint8Array. Am I missing something here? const client = new SESClient({config});
const input = { // SendRawEmailRequest
Source: "STRING_VALUE",
Destinations: [ // AddressList
"STRING_VALUE",
],
RawMessage: { // RawMessage
Data: "BLOB_VALUE", // required
},
FromArn: "STRING_VALUE",
SourceArn: "STRING_VALUE",
ReturnPathArn: "STRING_VALUE",
Tags: [ // MessageTagList
{ // MessageTag
Name: "STRING_VALUE", // required
Value: "STRING_VALUE", // required
},
],
ConfigurationSetName: "STRING_VALUE",
};
const command = new SendRawEmailCommand(input); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @mikelhamer, sorry for the confusion. Basically, the documentation says in a string which one is the type of data expected for each parameter, which in this case is "BLOB_VALUE" and not "STRING_VALUE". I know this can cause confusion sometimes and therefore I will pass this feedback to the documentation team. To address your specific need right now, the type of data for "Data" in JS is Uint8Array, which can be also confirmed here. To create a Uint8Array from a string you can use the TextEncoder API as follow: const encoder = new TextEncoder();
const uintArrayValue = encoder.encode("Here is the message you want to send"); I hope this helps! Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi @mikelhamer, sorry for the confusion. Basically, the documentation says in a string which one is the type of data expected for each parameter, which in this case is "BLOB_VALUE" and not "STRING_VALUE". I know this can cause confusion sometimes and therefore I will pass this feedback to the documentation team. To address your specific need right now, the type of data for "Data" in JS is Uint8Array, which can be also confirmed here.
To create a Uint8Array from a string you can use the TextEncoder API as follow:
I hope this helps!
Thanks!