You need to sign in to do that
Don't have an account?
Bohdan Dosiak 4
when i send it, in google i recive untitled file with unknown type
may be any solutions without JSON???
thx
create csv file and send to google
hi there
have a piece of code
how to create csv file and name it?
public static void sheets (List<Opportunity> oppo){ List<Opportunity > opps = [SELECT Id, Name, Description, CreatedDate, LastModifiedDate FROM Opportunity limit 10]; string header = '"Record Id","Name","Description","Created Date","LastModifiedDate" \n'; string finalstr = header ; for(Opportunity o: opps){ string recordString = '"'+o.id+'","'+o.Name+'","'+o.Description+'","'+o.CreatedDate +'","'+o.LastModifiedDate+'"\n'; finalstr = finalstr +recordString; } HttpRequest req = new HttpRequest(); req.setMethod('POST'); req.setEndpoint('callout:Googel_Sheets/upload/drive/v3/files'); req.setHeader('Content-Type', 'multipart/mixed'); req.setHeader('Content-length', String.valueOf(finalstr.length())); //required!!!! req.setTimeout(120000); req.setBody(finalstr); Http http = new Http(); HTTPResponse res = http.send(req); System.debug('RESPONSE ---> '+res.getStatus()); System.debug('RESPONSE ---> '+res.getBody()); System.debug('req ---> '+req); }
when i send it, in google i recive untitled file with unknown type
may be any solutions without JSON???
thx
Hi Bohadan,
U can upload the code in .txt format.
Also add Content-Disposition header with value = 'inline; filename="myfile.csv"'
Vinit Jogani
yup.
the same thing
This says that you also need a query paramter - uploadType=media