• Namita Choudhary
  • NEWBIE
  • 0 Points
  • Member since 2016

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

I have trying to do box integration with all approaches but nothinkg solved. The following approach seems to be easy but still not able to make call to box..
Basically we are trying this integration with Salesforce Box SDK Api (directly installed in salesforce platform) and trying to connect to box and get file Info (but actually we need upload and download, this SDK api has those methods to do that). Please find any clue on that issue and let me know. please look at this steps I followed

Step1: created box app for client id and client secret
2: got Access Token and Refresh Token using postman service
3. used these in following Apex code.
4. when I tried to Attach a file I get the following error.
 
Error:
19:36:28:488 USER_DEBUG [22]|DEBUG| Exception $$$$$$ An unexpected error occurred when trying to make a callout to the Box API. Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://api.box.com/oauth2/token

And the Apex code is...
 
public class BoxIntegrationClass{
    private static String CLIENT_ID='xxxxxx';
    private static String CLIENT_SECRET='yyyyy';
    private static String ACCESS_TOKEN='yyyyy';
    private static String REFRESH_TOKEN='yyyyy';
    @future (callout=true)
    public static void createAttachment(id attachmentid){
        System.debug('In Integration class  ');        
        BoxApiConnection api = new BoxApiConnection(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN,REFRESH_TOKEN); //This is successfully executed
        System.debug('api ---- '+api); 
        Attachment myAttachment=[select name,body,parentid from attachment where id=:attachmentid];
        BoxFile file = new BoxFile(api, '034192123421'); //This is failing, the error is above 
        try{
        	String previewLink = file.getPreviewLink();
        	System.debug('file link '+previewLink); 
        }catch(Exception e){
            System.debug(' Exception $$$$$$ '+e.getMessage());
        }
    }
}
I don't understand why its failing... please help on this.