Skip to Content
0

Send params in request body HANA XSJS

Dec 21, 2016 at 12:01 PM

129

avatar image

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

postman.jpg (52.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers