cancel
Showing results for 
Search instead for 
Did you mean: 

Send params in request body HANA XSJS

Former Member
0 Kudos

Hello,

i made some requests using xsjs, calling external webservices, but now I need to call and pass the params in the request body, not in the url as i have been doing.

So, i need to generate this exact call, which i now it works i postman

here is my code, wich does not work.

var res;

var response;
var dest = $.net.http.readDestination(destination_package, destination_name);
var client = new $.net.http.Client();
	 
var req = new $.web.WebRequest($.net.http.POST, "upload_file");
//var req = new $.net.http.Request($.net.http.POST, "upload_file");
req.setBody(JSON.stringify({
        action:"upload_file",
        id: id,
        filename: filename,
        extension: extension,
        checksum: checksum,
        type_id: typeId,
        the_file: theFile,
        user_id: userId
       }));
       
client.request(req, dest);
response = client.getResponse();
res = response.body.asString();

So, i must be missing something, but I don't know what. I tryed with $.net.http.Request instead of $.web.WebRequest but the result is the same.

Please, any help would be appreciated.

Thank you

Accepted Solutions (0)

Answers (1)

Answers (1)

SudarshanS
Participant
0 Kudos

Hello Luis - am looking to make an exact similar call. Please can you share if and how you fixed this.

Thanks

Sudarshan