api.httpCall: Endpoint Fails to Respond With Large Payload

When calling an external webservice via api.httpCall with large payloads, the request:

  • Sometimes fails when sent from Pricefx despite the endpoint being available

  • Succeeds when sent from Postman

Reason

The issue depends on how HTTP connections are managed. For example, the SAP webservice endpoint is sensitive to persistent (keep-alive) HTTP connections, and may fail to respond correctly unless the connection is explicitly closed after each request.

Solution (Workaround)

Add the Connection: Close header to force the connection to close after the request:

Groovy
def props = [
  "basicAuthenticationUserName" : "userName",
  "basicAuthenticationPassword" : "password",
  "additionalHeaders" : [ "Connection": "Close" ]  // ✅ this is the fix
]

Object result = api.httpCall(wsUrl, payload, "POST", "JSON", props)

The "Connection": "Close" header ensures that the TCP connection is not reused, avoiding compatibility issues with connection/threading model that may cause timeouts or dropped responses with large or repeated payloads.