• Abhishek Singh 116
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
Hi,

I am working on salesforce integration with Amazon using Amazon MWS. I am getting error code 403 and status : Forbidden.
"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." 

I have used every possible way to resolve this but getting same error again and again.
Code is given below:
public class Amazon_Integration {
    
    public String action = 'SubmitFeed';
    public String FeedType ='_POST_PRODUCT_DATA_';
    Public string accessKey = 'AKIexampleOKHWA';
    Public string MarketplaceId = 'AexampleDER';
    Public string SellerId = 'AUexampleRCX';
    Public string SignatureMethod='HmacSHA256';
    Public string SignatureVersion='2';    
    Public string version='2009-01-01';
    Public string amazonSecretKey='9YexampleWQMeM';
    Public string mwstoken = 'amzn.mws.example.9f650';
    public string endpoint = 'https://mws.amazonservices.com/Feeds/2009-01-01';        
    
    //Prepare the feed 
	public String prepare_body(String sellerId){
        
       String xmlBody = '<?xml version="1.0" encoding="UTF-8"?>' + 
                     '<AmazonEnvelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">'+
                         '<Header>' +
                         '<DocumentVersion>1.01</DocumentVersion>' +
                         '<MerchantIdentifier>' + sellerId + '</MerchantIdentifier>' +
                         '</Header>' +
                         '<MessageType>Product</MessageType>' +                         
                         '<Message>' +
                             '<MessageID>1</MessageID>' +
                             '<OperationType>Update</OperationType>' +
                             '<Product>' +
                                 '<SKU>56789</SKU>' +
                                 '<StandardProductID>' +
                                 '<Type>ASIN</Type>' +
                                 '<Value>B0EXAMPLEG</Value>' +
                                 '</StandardProductID>' +
                                 '<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>' +
                                 '<DescriptionData>' +
                                     '<Title>Example Product Title</Title>' +
                                     '<Brand>Example Product Brand</Brand>' +
                                     '<Description>This is an example product description.</Description>' +
                                     '<BulletPoint>Example Bullet Point 1</BulletPoint>' +
                                     '<BulletPoint>Example Bullet Point 2</BulletPoint>' +
                                     '<MSRP currency="USD">25.19</MSRP>' +
                                     '<Manufacturer>Example Product Manufacturer</Manufacturer>' +
                                     '<ItemType>example-item-type</ItemType>' +
                                  '</DescriptionData>' +
                                  '<ProductData>' +
                                    '<Health>' +
                                      '<ProductType>' +
                                        '<HealthMisc>' +
                                          '<Ingredients>Example Ingredients</Ingredients>' +
                                          '<Directions>Example Directions</Directions>' +
                                        '</HealthMisc>' +
                                      '</ProductType>' +
                                     '</Health>' +
                                   '</ProductData>' +
                                '</Product>' +
                             '</Message>' +
                           '</AmazonEnvelope>';                                              
            
            return xmlBody;
    }
    
    public String get_contentmd5(String xmlBody){
        	Blob targetBlob = Blob.valueOf(xmlBody);
        	Blob hash = Crypto.generateDigest('MD5', targetBlob);    
        	String contentMD5 = EncodingUtil.base64Encode(hash);
        	contentMD5 =  EncodingUtil.URLENCODE(contentMD5,'UTF-8');                    
        	return contentMD5;
    }
    
    public string send_feed_to_amazon(String xmlBody, String ContentMD5){

        String timestamp = datetime.now().formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
        timestamp = EncodingUtil.urlEncode(timestamp,'UTF-8');
        
        //Construct a query string with the query information
        String queryString = 'AWSAccessKeyId=' + accessKey + 
            '&Action=SubmitFeed'+
            '&ContentMD5Value=' + ContentMD5 +
            '&FeedType=_POST_PRODUCT_DATA_'+
            '&MWSAuthToken=' + mwstoken +   
            '&MarketplaceId.Id.1=' + MarketplaceId  +
            '&SellerId=' + SellerId +                                         
            '&SignatureMethod=' + SignatureMethod  +
            '&SignatureVersion=' + SignatureVersion  +
            '&Timestamp=' + timestamp  +
            '&Version=' + version;

        String stringtoSign = 'POST' + '\n' +
            'mws.amazonservices.com' + '\n' +
            '/Feeds/2009-01-01' + '\n' +
            queryString;               
        
        //Covert query string to signature using Amazon secret key as key
        Blob mac = Crypto.generateMac('HMacSHA256', 
        blob.valueof(stringtoSign),blob.valueof(amazonSecretKey));

        String signature = EncodingUtil.base64Encode(mac);
        signature = EncodingUtil.urlEncode(signature,'UTF-8');        

       //Create a new request
       HttpRequest request = new HttpRequest();    
        
       request.setEndpoint(endpoint +'?AWSAccessKeyId=' + accessKey +
                		   '&Action=SubmitFeed'+                                                                                 
                           '&FeedType=_POST_PRODUCT_DATA_'+                                                      
                           '&MWSAuthToken=' + mwstoken +
                           '&MarketplaceIdList.Id.1=' + marketplaceId +
                           '&SellerId=' + sellerId +
                           '&ContentMD5Value=' + ContentMD5 +
                           '&SignatureMethod='+ signatureMethod +
                           '&SignatureVersion=2' +
                           '&Timestamp=' + timestamp +
                           '&Version=' + version +                           
                           '&Signature=' + signature);
        
        request.setMethod('POST');
        request.setHeader('Content-type', 'text/xml');        
        request.setBody(xmlBody);        
        
        Http http = new Http();
        try {
            HttpResponse response = http.send(request);
            string status=response.getStatus();           
            System.debug(response.getStatus());
            System.debug(response.getStatusCode());            
            System.debug(response.getBody());            
            return status;
        } 
        catch(System.CalloutException e) {
            System.debug(e);
            return string.valueOf(e);
        }        
	}
}

Please help!!

Thanks in advance!!
 
I have written a process builder which has a scheduled action. I have a date field named "Discarded date". My process builder fires on created and edited the record and if Discarded date is not equal to blank.

So I want to perform an action after Discarded date + 10 days.

Now my question is: I created a record, I set Discarded date as 1st January. So ideally process builder would fire the action on 11th January (10 days after Discarded date). But if I change the Discarded date after 2 days, If I make it 5th January then when the action will fire? 11th January or 15th January?

Please help.

Thanks in Advance.
 
I am using a Visualforce email Template. I am unable to fetch merge fields. Below is the code:

<messaging:emailTemplate subject="Volunteer still needed for a shift" recipientType="User" relatedToType="GW_Volunteers__Volunteer_Shift__c">
<messaging:plainTextEmailBody >

Volunteer is still needed for a future shift. Please click below to see the shift.
https://cs18.salesforce.com/{!relatedToType.Id}

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

When I try to save it, it gives error like
Error:Unknown property 'String.Id'
Hi,

In Workflow rules while updating a field we have a option to check "Re-evaluate Workflow Rules after Field Change".

I just want to know, do we have such option in Process Builder?

Thanks!!
I have a inputText field in visualforce page like below:
<apex:inputText id="brhdate" size="10" value="{!findValue}" onmouseover="initialiseCalendar(this, '{!$Component.brhdate}')" />

I used Get, Set in the controller like below:

public String findValue { 
get { 
       Date dt = contact.Birthdate;
       findValue = dt.format();
        return findValue;}
set;
}
Get function is simply fetching the existing Birthdate value from contact in locale format and returning string.

Now in my main class when I use this variable, it didn't give the value which I changed in visualforce page.
public PageReference saveChange() { 
        contact.Birthdate = Date.parse(findValue);
        System.debug('Value of findValue ' + findValue)
}

When I click on save button, I only get the value which exist in the contact record already. I am not getting the new value which I changed in VisualForce page. Please help.

Thank you in advance!!
I am using visualforce site, there I have a inputtext button which is binded to contact standard button "Birthdate". The date formate in Birthdate field field is MM/DD/YYYY. But when my visualforce site getting loaded it shows the format like "Fri May 20 00:00:00 GMT 2016". I want to show the date in MM/DD/YYYY format only. Please help.

Visualforce code is below:
<apex:inputText id="brhdate" size="10" value="{!contactEdit.Birthdate}"  html-readonly="true" onmouseover="initialiseCalendar(this, '{!$Component.brhdate}')" />

This is a inputText field so we can also enter value using calender. But it also should appear the value if it exist in that contact already.
My problem is while site is loaded, this field shows existing date in different format like "Fri May 20 00:00:00 GMT 2016". Please tell me how can I show the date in MM/DD/YYYY.

Thanks you in advance.
 
I am using a Visualforce email Template. I am unable to fetch merge fields. Below is the code:

<messaging:emailTemplate subject="Volunteer still needed for a shift" recipientType="User" relatedToType="GW_Volunteers__Volunteer_Shift__c">
<messaging:plainTextEmailBody >

Volunteer is still needed for a future shift. Please click below to see the shift.
https://cs18.salesforce.com/{!relatedToType.Id}

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

When I try to save it, it gives error like
Error:Unknown property 'String.Id'
Hi,

I am working on salesforce integration with Amazon using Amazon MWS. I am getting error code 403 and status : Forbidden.
"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." 

I have used every possible way to resolve this but getting same error again and again.
Code is given below:
public class Amazon_Integration {
    
    public String action = 'SubmitFeed';
    public String FeedType ='_POST_PRODUCT_DATA_';
    Public string accessKey = 'AKIexampleOKHWA';
    Public string MarketplaceId = 'AexampleDER';
    Public string SellerId = 'AUexampleRCX';
    Public string SignatureMethod='HmacSHA256';
    Public string SignatureVersion='2';    
    Public string version='2009-01-01';
    Public string amazonSecretKey='9YexampleWQMeM';
    Public string mwstoken = 'amzn.mws.example.9f650';
    public string endpoint = 'https://mws.amazonservices.com/Feeds/2009-01-01';        
    
    //Prepare the feed 
	public String prepare_body(String sellerId){
        
       String xmlBody = '<?xml version="1.0" encoding="UTF-8"?>' + 
                     '<AmazonEnvelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">'+
                         '<Header>' +
                         '<DocumentVersion>1.01</DocumentVersion>' +
                         '<MerchantIdentifier>' + sellerId + '</MerchantIdentifier>' +
                         '</Header>' +
                         '<MessageType>Product</MessageType>' +                         
                         '<Message>' +
                             '<MessageID>1</MessageID>' +
                             '<OperationType>Update</OperationType>' +
                             '<Product>' +
                                 '<SKU>56789</SKU>' +
                                 '<StandardProductID>' +
                                 '<Type>ASIN</Type>' +
                                 '<Value>B0EXAMPLEG</Value>' +
                                 '</StandardProductID>' +
                                 '<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>' +
                                 '<DescriptionData>' +
                                     '<Title>Example Product Title</Title>' +
                                     '<Brand>Example Product Brand</Brand>' +
                                     '<Description>This is an example product description.</Description>' +
                                     '<BulletPoint>Example Bullet Point 1</BulletPoint>' +
                                     '<BulletPoint>Example Bullet Point 2</BulletPoint>' +
                                     '<MSRP currency="USD">25.19</MSRP>' +
                                     '<Manufacturer>Example Product Manufacturer</Manufacturer>' +
                                     '<ItemType>example-item-type</ItemType>' +
                                  '</DescriptionData>' +
                                  '<ProductData>' +
                                    '<Health>' +
                                      '<ProductType>' +
                                        '<HealthMisc>' +
                                          '<Ingredients>Example Ingredients</Ingredients>' +
                                          '<Directions>Example Directions</Directions>' +
                                        '</HealthMisc>' +
                                      '</ProductType>' +
                                     '</Health>' +
                                   '</ProductData>' +
                                '</Product>' +
                             '</Message>' +
                           '</AmazonEnvelope>';                                              
            
            return xmlBody;
    }
    
    public String get_contentmd5(String xmlBody){
        	Blob targetBlob = Blob.valueOf(xmlBody);
        	Blob hash = Crypto.generateDigest('MD5', targetBlob);    
        	String contentMD5 = EncodingUtil.base64Encode(hash);
        	contentMD5 =  EncodingUtil.URLENCODE(contentMD5,'UTF-8');                    
        	return contentMD5;
    }
    
    public string send_feed_to_amazon(String xmlBody, String ContentMD5){

        String timestamp = datetime.now().formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
        timestamp = EncodingUtil.urlEncode(timestamp,'UTF-8');
        
        //Construct a query string with the query information
        String queryString = 'AWSAccessKeyId=' + accessKey + 
            '&Action=SubmitFeed'+
            '&ContentMD5Value=' + ContentMD5 +
            '&FeedType=_POST_PRODUCT_DATA_'+
            '&MWSAuthToken=' + mwstoken +   
            '&MarketplaceId.Id.1=' + MarketplaceId  +
            '&SellerId=' + SellerId +                                         
            '&SignatureMethod=' + SignatureMethod  +
            '&SignatureVersion=' + SignatureVersion  +
            '&Timestamp=' + timestamp  +
            '&Version=' + version;

        String stringtoSign = 'POST' + '\n' +
            'mws.amazonservices.com' + '\n' +
            '/Feeds/2009-01-01' + '\n' +
            queryString;               
        
        //Covert query string to signature using Amazon secret key as key
        Blob mac = Crypto.generateMac('HMacSHA256', 
        blob.valueof(stringtoSign),blob.valueof(amazonSecretKey));

        String signature = EncodingUtil.base64Encode(mac);
        signature = EncodingUtil.urlEncode(signature,'UTF-8');        

       //Create a new request
       HttpRequest request = new HttpRequest();    
        
       request.setEndpoint(endpoint +'?AWSAccessKeyId=' + accessKey +
                		   '&Action=SubmitFeed'+                                                                                 
                           '&FeedType=_POST_PRODUCT_DATA_'+                                                      
                           '&MWSAuthToken=' + mwstoken +
                           '&MarketplaceIdList.Id.1=' + marketplaceId +
                           '&SellerId=' + sellerId +
                           '&ContentMD5Value=' + ContentMD5 +
                           '&SignatureMethod='+ signatureMethod +
                           '&SignatureVersion=2' +
                           '&Timestamp=' + timestamp +
                           '&Version=' + version +                           
                           '&Signature=' + signature);
        
        request.setMethod('POST');
        request.setHeader('Content-type', 'text/xml');        
        request.setBody(xmlBody);        
        
        Http http = new Http();
        try {
            HttpResponse response = http.send(request);
            string status=response.getStatus();           
            System.debug(response.getStatus());
            System.debug(response.getStatusCode());            
            System.debug(response.getBody());            
            return status;
        } 
        catch(System.CalloutException e) {
            System.debug(e);
            return string.valueOf(e);
        }        
	}
}

Please help!!

Thanks in advance!!
 
Hi,

In Workflow rules while updating a field we have a option to check "Re-evaluate Workflow Rules after Field Change".

I just want to know, do we have such option in Process Builder?

Thanks!!
I am using visualforce site, there I have a inputtext button which is binded to contact standard button "Birthdate". The date formate in Birthdate field field is MM/DD/YYYY. But when my visualforce site getting loaded it shows the format like "Fri May 20 00:00:00 GMT 2016". I want to show the date in MM/DD/YYYY format only. Please help.

Visualforce code is below:
<apex:inputText id="brhdate" size="10" value="{!contactEdit.Birthdate}"  html-readonly="true" onmouseover="initialiseCalendar(this, '{!$Component.brhdate}')" />

This is a inputText field so we can also enter value using calender. But it also should appear the value if it exist in that contact already.
My problem is while site is loaded, this field shows existing date in different format like "Fri May 20 00:00:00 GMT 2016". Please tell me how can I show the date in MM/DD/YYYY.

Thanks you in advance.