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
Elavarasan BalasubramaniyanElavarasan Balasubramaniyan 

PostMan to apex class

Using Http Method Post Method

How to write a Apex class to get through the file in Apex class

I have tried with the Following code

@HttpPost global static String dopost(){
string boundary;
RestRequest req = RestContext.request;
system.debug(req); Blob body = req.requestBody;
system.debug(body);
string body1 =body.toString();
system.debug(body1);
/*String boundary = '----------------------------9woZbkLDjbVEehiu';
string body2 = '--' +boundary + '\nContent-Disposition: form-data; ' + 'name="Elavarasan"; ' + 'filename="' + body1.filename; + '";\nContent-Type: text/plain';
*/ /*Blob body2 = EncodingUtil.base64Decode(body1);
System.debug(body2);*/ //system.debug(body1.filename);
string[] accountDataLines = new String[] {};
accountDataLines = body1.split('\n\n\n');
system.debug(accountDataLines[0]);
//dto df = (dto)json.deserialize(accountDataLines[0],dto.class);
string[] csvFieldNames = accountDataLines[0].split('"name"');
system.debug(csvFieldNames); system.debug(csvFieldNames.size());
/*for (Integer i = 0; i < csvFieldNames.size(); i++) {
system.debug(csvFieldNames.size());
system.debug(csvFieldNames[i]);
*/ string[] csvFieldNames1 = body1.split('"phone"');
system.debug(csvFieldNames1);
account cf = new account();
//cf.Name=csvFieldNames;
//system.debug(cf.Name);
//cf.phone=csvFieldNames1;
//system.debug(cf.phone);
string[] csvFieldNames2 = body1.split('"Website"');
// cf.Website=csvFieldNames2;
//system.debug(cf.Website); return null; }
public class dto {
public string Name{get;set;}
public string phone{get;set;}
public string website{get;set;} }

I am unable to seperate the Blob body ,because it contains Header ,footerValue then how i will get the body of the file Content,can anyone please help for the Answer