Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

XSJS - Outbound HTTP Request - POST

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;}

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question