How do I use the pPostData parameter in tsNetPost?
Posted: Tue Aug 20, 2019 2:08 am
I'm trying to teach myself how to get LC Desktop to transmit data to LC Server
1) On LC Server I have this script -
<?lc
put empty into tData
repeat for each key tKey in $_SERVER
put tKey & " : " & $_SERVER[tkey] & return after tData
end repeat
put "===================" & return after tData
put "xcontent : " & $_GET["xcontent"] after tData
put tData
?>
2) On LC Desktop I have a button that runs this script (note that there is no pPostData parameter) -
put tsNetPost(("Conn" & random(1000)),"https://www.mysite.com/myscript.lc?xcon ... ntent-Type: text/plain",,"APIResponseFromDataReceipt") into tFatalErrorsFromAPI
When I activate this button - my APIResponseFromDataReceipt handler returns what I'm expecting, including:
$_Server["QUERY_STRING"] contains "xcontent=ABC"; and
$_GET["xcontent"] contains "ABC"
3) Then I change my LC Desktop script to utilise the pPostData parameter -
put tsNetPost(("Conn" & random(1000)),"https://www.mysite.com/myscript.lc","Content-Type: text/plain","xcontent=ABC","APIResponseFromDataReceipt") into tFatalErrorsFromAPI
When I activate this button - my APIResponseFromDataReceipt handler returns:
$_Server["QUERY_STRING"] contains empty; and
$_GET["xcontent"] contains empty
In the tsNetPost with a pPostData parameter, I've tried:
- having the "?" as a suffix to the pURL parameter
- having the "?" as a prefix to the pPostData parameter
- not having the "?" in either the pURL or pPostData parameter
- removing the "Content-Type: text/plain"
But none of these options made any difference. In all cases $_Server["QUERY_STRING"] and $_GET["xcontent"] returned empty.
What is the correct format for using tsNetPost > pPostData to transmit a "xcontent=ABC" query string to LC Server? Or am I misunderstanding things and "xcontent=ABC" is not "the data to be posted to the server" (as per the dictionary entry)?
Thanks in advance
Kim
1) On LC Server I have this script -
<?lc
put empty into tData
repeat for each key tKey in $_SERVER
put tKey & " : " & $_SERVER[tkey] & return after tData
end repeat
put "===================" & return after tData
put "xcontent : " & $_GET["xcontent"] after tData
put tData
?>
2) On LC Desktop I have a button that runs this script (note that there is no pPostData parameter) -
put tsNetPost(("Conn" & random(1000)),"https://www.mysite.com/myscript.lc?xcon ... ntent-Type: text/plain",,"APIResponseFromDataReceipt") into tFatalErrorsFromAPI
When I activate this button - my APIResponseFromDataReceipt handler returns what I'm expecting, including:
$_Server["QUERY_STRING"] contains "xcontent=ABC"; and
$_GET["xcontent"] contains "ABC"
3) Then I change my LC Desktop script to utilise the pPostData parameter -
put tsNetPost(("Conn" & random(1000)),"https://www.mysite.com/myscript.lc","Content-Type: text/plain","xcontent=ABC","APIResponseFromDataReceipt") into tFatalErrorsFromAPI
When I activate this button - my APIResponseFromDataReceipt handler returns:
$_Server["QUERY_STRING"] contains empty; and
$_GET["xcontent"] contains empty
In the tsNetPost with a pPostData parameter, I've tried:
- having the "?" as a suffix to the pURL parameter
- having the "?" as a prefix to the pPostData parameter
- not having the "?" in either the pURL or pPostData parameter
- removing the "Content-Type: text/plain"
But none of these options made any difference. In all cases $_Server["QUERY_STRING"] and $_GET["xcontent"] returned empty.
What is the correct format for using tsNetPost > pPostData to transmit a "xcontent=ABC" query string to LC Server? Or am I misunderstanding things and "xcontent=ABC" is not "the data to be posted to the server" (as per the dictionary entry)?
Thanks in advance
Kim