Quantcast
Channel: SCN : All Content - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6745

XSJS - Outbound HTTP Request - POST

$
0
0

I try to send a record to HTTP destination (REST services) using POST method. execution of the code takes to else loop and return  "No Response: Issue with the Coding Part". Do let me know, if any part mentioned wrong in the code. Appreciate the help

 

Note: HTTP destination and xsjs file stored in same package

 

 

try {

    var query = 'SELECT "MATERIALNUMBER","DIVISION","CUST_GRP1" ' + 'FROM \"PVENKATA\".\"MATERIAL_PRICING\" where "MATERIALNUMBER" = \'XXXXX\'';

    var conn = $.db.getConnection();

    var pstmnt = conn.prepareStatement(query);

    var result = pstmnt.executeQuery();

 

  var client = new $.net.http.Client();

  var destination = $.net.http.readDestination("pkg-pvenkata.SIAL_XS1", "MATPRICE_CALL");

  var request =new $.net.http.Request($.net.http.POST, "result");

 

  client.request(request, destination);

  var response = client.getResponse();

 

  if(response.body){

   $.response.setBody(response.body.asString());

  }

  else {

   $.response.setBody( "No Response: Issue with the Coding Part" );

  }

  

  $.response.status = response.status;

  $.response.contentType = "application/json";

  }

  catch(x){

   $.response.status = 500;

   $.response.setBody( e.message );

   $.response.status = $.net.http.INTERNAL_SERVER_ERROR;}


Viewing all articles
Browse latest Browse all 6745

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>