Hello everyone,
I'm experiencing inexplicable differences in the REST API query between execution as a PRG in the IDE and execution in the compiled Client.exe.
*-- Client-Code
*-- Create JSON-parameter
lcJSONParameter = '{"TableName":"' + tcTableName + '","Parameter":"' + tcParameter + '","Debug":"YES","ID":' + ;
Num2C( tnID ) + ',"UseXML":' + Num2C( lnUseXML ) + ',"Fields":"' + lcFields + '","Order":"' + lcOrder + '"}'
*-- Filter as parameter in JSON-string
goHttp.cContentType = 'application/json'
lcData = goHttp.POST( gcURL + 'GetData.wc', lcJSONParameter )
*-- Server-Code
FUNCTION GetData( loParameter AS OBJECT )
*****************************************
*-- 25.03.26 HPG: Q&D
IF VARTYPE( loParameter ) <> 'O'
*-- Get JSON from cFormsVar
lcJSONParameter = Request.FormXML()
loParameter = JsonDeserialize( lcJSONParameter )
ENDIF
lcTableName = loParameter.TableName
When I run the client code in the IDE using Ctrl+E, the server creates the loParameter object.
However, when I run the client code in the compiled EXE, the server does not create an loParameter object.
As a quick workaround, I can retrieve the JSON data from cFormVar using Request.FormXML().
What's going wrong here, or what am I missing?
If the client is in question you should debug the client and make sure you're sending what you think you're sending by logging out your outgoing payload.
Also be aware that you are hard coding JSON. If the JSON is malformed - ie. there's something that should be encoded that is not, the JSON conversion on the server will fail and result in no object passed.
You should never create JSON by hand like you're doing in the example - always run through a parser to ensure that the data is properly encoded.
+++ Rick ---