0

I have requirement to fetch a file from s3 server to Salesforce. As a part of Summer'19 release, Salesforce has provided AWS Signature Version 4 protocol in Named credential.From below link I see that someone has already implemented PUT functionality using this credential - AWS Signature Version 4 Using Named Credentials. So I tried to implement the similar way and configured Named credential as below-

Name- aws_callout
url - https://bucketName.s3.amazonaws.com
Identity Type - Named Principal
Authentication Protocol - AWS Signature Version 4
AWS Access Key ID - ******
AWS Secret Access Key - ********
AWS Region - us-east-1
AWS Server- s3
Generate Authorization Header - true

-----Code----

public class awsCallout{
    public static void callout(){
        HttpRequest req = new HttpRequest();
        req.setEndpoint('callout:aws_callout/Test/item');
        req.setMethod('GET');
        Http http = new Http();
        System.debug(req);
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());
    }
}

I see the response as

<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>C6404B9BB1DB25CF</RequestId><HostId>et0i9RS/EHkv0y6+a9x6F8x08xmAD/tYJP9hENH51kT4aVOf6wE9aL89UZH3I/Uz+y+WsMCLjjI=</HostId></Error>

When I check my fine logs I see that Authorization = "Not Set" as below

NAMED_CREDENTIAL_REQUEST NamedCallout[Name=aws_callout2, Endpoint=https://bucketName.s3.amazonaws.com/Test/item, Method=GET, External Credential Type=EXTERNAL, HTTP Header Authorization=Not Set, Retry on 401=True]

I am not sure why Authorization is showing as "Not Set" even though I have marked as true for "Generate Authorization Header" in Named credential Can someone help me out solving this issue?

PS - I am able to access this file through Postman

3
  • You have Name- aws_callout but you're using aws_callout2 in your code. Typo or a root cause of why it's not working?
    – identigral
    Commented Sep 12, 2019 at 22:38
  • @identigral- sorry its a typo error here.I have updated to aws_callout but still result in same error
    – Raji
    Commented Sep 13, 2019 at 3:30
  • Please add the request/response from Postman
    – identigral
    Commented Sep 13, 2019 at 15:23

0

You must log in to answer this question.

Browse other questions tagged .