You need to sign in to do that
Don't have an account?
Sumant Kuchipu 1
Salesforce-Box using BOX SDK API issue
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.
And the Apex code is...
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.
It seems you havn't created remote site settings for box.
Go to
Setup->Security->Remote site settings
Add this url as end point URL
https://api.box.com/oauth2/token
for more info
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_remotesitesetting.htm
Let me know if you have any issues.
Mark it as best answer if it works.
Thanks.
Still not understanding whats wrong here and don't know how to refresh token..
i.e. Named Credentials in Salesforce, this is really great feature.
Thanks..
I am using BoxApiConnection API, and noticed that every time when I initialize as api = new BoxApiConnection(clientId, clientSecret, accessToken, refreshToken); it is refreshing the accessToken and refreshToken values. My understanding is accessToken is valid for an 1 hr, and refreshToken is for 60 days according to Box documentation. Have you come across this situation. You mentioned that you have used Named Credentials rather than custom settings to store tokens. Have you Named Credentials with BoxApiConnection (box-salesforce-sdk) or with BOX REST API? Could you please share the detailed solution with bit of sample code to see how you achevied this?
Thanks
Tom
I need bit of your help. I am trying to use Named Credentials for Box integration and kind of stuck. My reqirement is to move file from one folder to another folder.
In the Named Credentials I have specified Url as https://api.box.com/2.0/
Now I need to help with the apex code, could you please share bit of code which you actally did either it is folder creation or anything. I just tried simple as follows to get a folder info and it is not working.
Also I have created Auth Provider in Salesforce with the Box client_id and client_secret, and selected Open ID Connect as Provider Type, followed https://help.salesforce.com/articleView?id=admin_files_connect_box_auth.htm&language=en_US&type=0.
Could you please share anything else I need to setup based on your expereice.
Really appreciate your help on this.
Thanks
Tom
I got it working.. thanks anyway.
Cheers,
Tom
Can you please explain that what did you do to got it working fine ?
Thanks !
I am tryiing to integrate sallesforcw eith box and want to upload a file to box using box sdk.
Can you explain how did you get the fileID which you ahve passed in "BoxFile file = new BoxFile(api, '034192123421');"?
Thanks for he help in advance 1.
Regards,
Sowmya