Web Connection
Trying to send a 204 response
Gravatar is a globally recognized avatar based on your email address. Trying to send a 204 response
  Ron Jasper
  All
  Aug 27, 2025 @ 02:18pm

Hi Rick, I know this is a really basic question, but how do I return a valid 204 response from my webconnection function? The txt file gets created from the object passed by the point-of-sale without a problem, but the calling webhook from the point-of-sale is not receiving the 204 response. Do I just return the entire response object?

FUNCTION l_readFromLswhSaleUpdate  && needs to creates a text file from passed object and returns a 204 response
LPARAMETERS po_loFromLsSaleUpdate
LOCAL loJsonSerializer, lcJson
loJsonSerializer = CREATEOBJECT("wwJsonSerializer")
lcJson = loJsonSerializer.serialize(po_loFromLsSaleUpdate)
STRTOFILE(lcJson,"lsjson\l_"+GetUniqueId()+".txt")
Response.Status = "204 No Content"
RELEASE loJsonSerializer, lcJson
RETURN
ENDFUNC
Gravatar is a globally recognized avatar based on your email address. re: Trying to send a 204 response
  Rick Strahl
  Ron Jasper
  Aug 28, 2025 @ 08:01am

For no content you need to literally return no content, so you can't return an JSON data (including null or "")

So you need to return an explicit empty response:

FUNCTION _204Response()
*** THIS! Forces no JSON conversion and no automatic result parsing
THIS.lRawResponse = .T.  

* ...  your code

Response.Status = "204 No Content"
RETURN

+++ Rick --

Gravatar is a globally recognized avatar based on your email address. re: Trying to send a 204 response
  Ron Jasper
  Rick Strahl
  Aug 28, 2025 @ 09:03am

Got it, thanks.

© 1996-2025