'S3 bukcet getobject throws error Method not found: 'Amazon.Runtime.Internal.Transform.UnmarshallerContext

I am tring to read my s3 bucket object from EKS cluster application method as listed below.

   [HttpGet("ReadFromS3")]

    [ProducesResponseType(typeof(ApiResponse<string>), 200)]

    [ProducesResponseType(500)]

    public async Task<String> ReadFromS3()

    {

        AmazonS3Config config = new AmazonS3Config { RegionEndpoint = RegionEndpoint.EUWest2 };



        string aws_tokenFile = Environment.GetEnvironmentVariable("AWS_WEB_IDENTITY_TOKEN_FILE");

        string aws_rolw_arn = Environment.GetEnvironmentVariable("AWS_ROLE_ARN");



        string logs = string.Empty;



        using (var stsClient = new AmazonSecurityTokenServiceClient(new AnonymousAWSCredentials()))

        {

            logs += "AmazonSecurityTokenServiceClient";



            var assumeRoleResult = await stsClient.AssumeRoleWithWebIdentityAsync(new AssumeRoleWithWebIdentityRequest

            {

                WebIdentityToken = System.IO.File.ReadAllText(Environment.GetEnvironmentVariable("AWS_WEB_IDENTITY_TOKEN_FILE")),

                RoleArn = Environment.GetEnvironmentVariable("AWS_ROLE_ARN"), 

                RoleSessionName = "S3Session",

                DurationSeconds = 900

            });





            if (assumeRoleResult != null)

            {

                logs += " -> assumeRoleResult";



                var credentials = assumeRoleResult.Credentials;



                var basicCredentials = new BasicAWSCredentials(credentials.AccessKeyId,

                                     credentials.SecretAccessKey);



                logs += " -> BasicAWSCredentials";



                using (client = new AmazonS3Client(basicCredentials, RegionEndpoint.EUWest2)  )

                {

                    logs += " -> AmazonS3Client";



                    try

                    {

                        GetObjectRequest request = new GetObjectRequest

                        {

                            BucketName = bucketName,

                            Key = keyName

                        };

                        GetObjectResponse response = await client.GetObjectAsync(request);



                        logs += " -> GetObjectAsync";





                        Stream responseStream = response.ResponseStream;

                        StreamReader reader = new StreamReader(responseStream);



                        logs += " -> ResponseStream";



                        return await reader.ReadToEndAsync();

                    }

                    catch (Exception ex)

                    {

                        

                        return "Exception in ReadFromS3 :" + ex.Message + logs;

                    }

                }

            }

            else

            {

                return "Unable to Connect";

            }

        }

    }

I am getting error at line GetObjectResponse response = await client.GetObjectAsync(request);

Method not found: 'Amazon.Runtime.Internal.Transform.UnmarshallerContext Amazon.Runtime.Internal.Transform.ResponseUnmarshaller.CreateContext



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source