function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
marys pindamarys pinda 

File URL from Document Salesforce Schedulable

I have a code which gets information from a file-URL and creates a Document within the Salesforce.
I wish he created the document on the 10 am and then I used Schedulable.
But he has a problem and does not create the document.
Someone help me please!.

global class UploadFileTest implements System.Schedulable {
 //Public Document mydoc;         
    global void execute(SchedulableContext sc) {
        getFile();
    }
    
 public void  getFile(){
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://download.finance.yahoo.com/d/quotes.csv?s=AAPL,IBM&f=sl1d1t1c1ohgv&e=.csv');
    req.setMethod('GET');
    req.setHeader('Content-Type', 'text/csv');
    req.setCompressed(true);
    req.setTimeout(60000);
                  
    HttpResponse res = h.send(req);
    string responseValue = '';
    responseValue = res.getBody();
    system.debug('Response Body for File: ' + responseValue);
    blob image = res.getBodyAsBlob();
 
    Document mydoc = new Document();
    mydoc.Name = 'UPDATE';
    mydoc.Type = 'csv';
    mydoc.folderid = UserInfo.getUserId();
    mydoc.Body = image;
    insert mydoc;       
    }
}
THANK YOU!
Vinit_KumarVinit_Kumar
Refer to below post for answer,this is just the same :-

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AVgU
vanessa veronvanessa veron
Thank you!