Search code examples
c#amazon-web-servicesamazon-s3aws-sdkaws-sdk-net

Getting Timestamp error in AWS SDK .net


I'm trying to use Amazon's AWS SDK for .NET, S3 storage. I use this code:

using (var client = new AmazonS3Client(AwsAccessKey, AwsSecretAccessKey, new AmazonS3Config { ServiceURL = ServiceUrl }))
{                
    var request = new PutObjectRequest
    {
        BucketName = BucketName,
        Key = path,
        ContentBody = contents,
        ContentType = "text/plain"
    };
    client.PutObject(request);                
}

I keep getting this error (the value itself corresponds to DateTime.UtcNow.

Value (Tue, 31 Dec 2013 14:13:04 GMT) for parameter Timestamp is invalid. Must be in ISO8601 format.

I can't find any place to set a timestamp. Any suggestions?


Solution

  • Found the problem! Wrong ServiceUrl - duh!

    Should be https://s3-us-west-2.amazonaws.com instead of https://ec2.us-west-2.amazonaws.com

    Amazon could do a better job at displaying this url in their console.