When trying to AWS S3 via Named Credentials getting the error
PermanentRedirect
The bucket you are
attempting to access must be addressed using the specified endpoint.
Please send all future requests to this
endpoint.fol.s3-us-west-2.amazonaws.comfol
Actually it could be because of not including the bucket name in the URL and it might have been given as https://s3.ap-south-1.amazonaws.com/folder1/folder1a/.
Try the url as: https://s3.ap-south-1.amazonaws.com/bucket-name/folder1/folder1a/
You shoud get 200 Status Ok printed in the debug console. REST API code to connect to s3:
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:AWS_S3'); // named credentials name
req.setMethod('GET');
req.setHeader('Content-Type','application/xml');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
System.debug(res.getStatusCode());
System.debug(res.getStatus());