Search code examples
c#.netamazon-web-servicesamazon-ses

aws sdk sesv2 ListContactsAsync problem in C#


Can anyone confirm that this works for them in C#? I'm using v2 of ses and trying to get the list of contacts. I don't have any problem getting an individual contact and I definitely have my IAM user setup with SES:ListContacts permissions. The keys work for sendmail and getcontact but not for listcontacts. ListContacts works with the same user and credentials when I do it through the AWS CLI.

var client = new AmazonSimpleEmailServiceV2Client("ID", "SECRET_KEY");

/* works
var cRequest = new GetContactRequest();
cRequest.ContactListName = "fmContacts";
cRequest.EmailAddress = "[email protected]";
GetContactResponse response = await client.GetContactAsync(cRequest);

Console.Write(response.EmailAddress);
*/

// fails with 
var cRequest = new ListContactsRequest();
cRequest.ContactListName = "fmContacts";

ListContactsResponse response = await client.ListContactsAsync(cRequest);

Console.Write(response.Contacts);

Amazon.SimpleEmailV2.AmazonSimpleEmailServiceV2Exception: 'The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.'


Solution

  • ListContacts has a known issue with multiple AWS SDKs, including the AWS SDK for .NET. The SDK team has passed this along to the SES team.

    ListContacts is modeled as a GET request that also has a request body for the Filter parameter, which doesn't work well with .NET's HTTP client. This is why it works in some SDKs but not others.

    Some previous reports: