You need to sign in to do that
Don't have an account?
marys pinda
File URL from Document
Hello,
I have a file in a URL,
I would like to get the content of this file and create a Document.
I made this code, but it does not work, what I forgot to do?
Thank you
I have a file in a URL,
I would like to get the content of this file and create a Document.
I made this code, but it does not work, what I forgot to do?
global class UploadFileTest implements System.Schedulable { Public Document mydoc; global void execute(SchedulableContext sc) { test(); } public void test(){ Http h = new Http(); HttpRequest req = new HttpRequest(); string firstImageURL = 'download.finance.yahoo.com/d/quotes.csv?s=AAPL,IBM&f=sl1d1t1c1ohgv&e=.csv'; firstImageURL = firstImageURL.replace(' ', '%20'); req.setEndpoint(firstImageURL); req.setMethod('GET'); req.setHeader('Content-Type', 'text/csv'); req.setCompressed(true); req.setTimeout(60000); HttpResponse res = null; res = h.send(req); string responseValue = ''; responseValue = res.getBody(); system.debug('Response Body for File: ' + responseValue); blob image = res.getBodyAsBlob(); mydoc = new Document(); mydoc.Name = 'VOCAZA UPDATE'; mydoc.Type = 'csv'; mydoc.folderid = UserInfo.getUserId(); mydoc.Body = image; insert mydoc; } }
Thank you
I didn't use the schedulable context, but I just re-wrote your task a little so I could just run it in the anonymous context, and it ran fine;
...Also, I had to specift the protocol (http:) and specify the endpoint in the security controls.
From what I saw you did not change anything in my code, just took the Schedulable.
I would like to use the Schedulable to automate this action to create documents from files in URL.
I used your code with Schedulable, but the document is not created.
What should I do?
Somebody help me.
Thank you,