Sidebar

How do I force the content-type http header on a call when no content is sent?

0 votes
491 views
asked Apr 3, 2019 by ben-s-7515 (12,640 points)
I am making a REST web service call with no content, but the receiving system needs a content-type header.  When I use the content-type parameter for the web service call it is not passed to the remote system.

1 Answer

0 votes

The REST web service call will only include the content-type if there is content by default.  This is because the content-type header is a description of the payload or content of the web service call, if there is no content, then technically there should not be content-type.  However, there are some systems that still require the content-type header even if there is no content being sent.  To include the content-type header (and any other header desired), you can place the values in the parameterMap passed into the call.

var parameterMap = qie.newParameterMap();
parameterMap.put("http.header.content-type", 'application/xml');
parameterMap.put("http.header.headerName", 'someValue');
var urlTemplate = qie.evaluateTemplate(qie.getWsEndpointUrl('wsName'));
var response = qie.callRESTWebService(
   'MyConnection', // Web Service Connection Name
   'https://somesite.com/getData',  // URL to call
   'GET', // Operation
   null, // Content is null
   'application/xml', // Because content is null, this parameter is ignored
   parameterMap, // contains the header's that will be forced onto the call
   60000); // Call timeout
 

answered Apr 3, 2019 by ben-s-7515 (12,640 points)
...