Web Connection
Trying to send a 204 response
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
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 --