How to extract request body content which is csv file upload

Not applicable

Hi All,

I am uploading .csv file with 5 mb size in my SPA page, that i need to extract the data in okapi and convert to base64 encoded string ? Could any one guide me on this request please, I tried below to extarct payload using javascript, but it doesn't work

try {

var okapi_issued_ecsId = context.getVariable("Body");

context.setVariable("bdy", okapi_issued_ecsId);

}

catch(error) {

throw "Error in Javascript: " + error;

}

0 4 1,646
4 REPLIES 4

umannggoel
Participant II

What is the error your are getting, do you able to get the request data in "okapi_issued_ecsId" variable.

I believe it should be var okapi_issued_ecsId = context.getVariable("request.body");

thank you. context.getVariable("request.body"); extracted the content.. now my request body format looks like below

Content-Disposition: form-data; name="bulk-file"; filename="bulkfile3 .csv"

Content-Type: application/vnd.ms-excel

firstname,lastname,email, phoneno,homeaddresss (csv content goes here under respective column)

how do i remove the 1st and 2nd line and extract from firstname?

Wait, what are you doing? Can you clarify?

What is okapi?

You said you "need to extract the data in okapi" . What does that mean?

Uploading a file of 5mb to an API, then converting it to base64 in memory, seems like a bad idea.

What's the REAL goal?

You may want to check out https://github.com/DinoChiesa/Apigee-Java-Simple-MultipartForm

for parsing inbound forms.