In the above link it is given that we have to make a GET request to the downloadUrl (which we get in the response when we upload the file) in order to get the file contents.

The downloadUrl which I got after uploading file to google drive is : "downloadUrl": "https://doc-10-cc-docs.googleusercontent.com/docs/securesc/2butu3k0aok5svkleqovepe3uqqvauqr/9o0jdpikd3jl5krf0vgcacuhfl8gro0v/1408694400000/05688347114777583261/05688347114777583261/0B602YDdndVQ6LUxZRC0wX1ZtWWs?h=16653014193614665626&e=download&gd=true"

Now i am making GET request like this:

    Http http = new Http();
    HttpRequest req = new HttpRequest();
    req.setHeader('content-type', 'text/plain');
    req.setHeader('Authorization','Bearer '+accessToken);
    HttpResponse resp = http.send(req);

My problem is that, each time i upload the file i will get different downloadUrl such that it is difficult to change the remote site settings every time.Any way to dynamically change the remote site setting? Please help me.

3 Answers 3


I got the solution to the above question. To get the contents of the uploaded file we can set end point like this:


instead of req.setEndpoint(downloadURL);

where ID is the file id which we get in the response.


You can use the meta data api - for remote settings One thing to note though is the user that is making the meta data api call to change the remote settings would need to have the same privilege in the UI

Here's some additional information http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_calls_intro.htm and http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_intro.htm


You can also use the exportLinks contains in the json It contains different urls of different formats. Example for PDF and EXCEL type :

 "exportLinks": {
        "application/pdf": "https://docs.google.com/spreadsheets/export?id=17qscm9Xp8NDA8fDwGgXd2-Er3gYdEIyd0D5Z0E6PcOU&exportFormat=pdf",
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/spreadsheets/export?id=17qscm9Xp8NDA8fDwGgXd2-Er3gYdEIyd0D5Z0E6PcOU&exportFormat=xlsx"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .