Submits JSON formatted data to the server and returns the result in
a buffer provided by the caller.
object.PostJson( Resource, JsonData,
Buffer, [Options] )
- A string that specifies the resource that the data will be
posted to on the server. Typically this is the name of an
- A string that contains the JSON formatted data which will be
provided to the script.
- A string or byte array that will contain the output generated
by the script. Typically this is HTML content which is generated by
the script as a result of processing the data that was posted to
- An optional integer value which specifies one or more options.
This argument is constructed by using a bitwise operator with any
of the following values:
||The default post mode. The contents of the buffer are
encoded and sent as standard form data. The data returned by
the server is copied to the result buffer exactly as it is
returned from the server.
||If the data being returned from the server is textual, it
is automatically converted so that the end of line character
sequence is compatible with the Windows platform. Individual
carriage return or linefeed characters are converted to
carriage return/linefeed character sequences. Note that this
option does not have any effect on the form data being
submitted to the server, only on the data returned by the
||This option causes the client to accept error data from the
server if the request fails. If this option is specified, an
error response from the server will not cause the method to
fail. Instead, the response is returned to the client and the
method will succeed.
A value of zero is returned if the operation was successful,
otherwise a non-zero error code is returned which indicates the cause
of the failure.
The PostJson method is used to submit JSON formatted data to
a script that executes on the server and then copy the output from
that script into a local buffer. This function automatically sets the
correct content type and encoding required for submitting JSON data to
a server, however it does not parse the JSON data itself to ensure
that it is well-formed. Your application is responsible for ensuring
that the JSON data that is being submitted to the server is formatted
It is common for servers to return additional information about a
failed request in their response to the client. If you need to process
this information, use the httpPostErrorData option which
causes the error message to be returned in the Buffer provided
by the caller. If this option is used, your application should check the
value of the ResultCode property to obtain the HTTP status code
returned by the server. This will enable you to determine if the
operation was successful.
This method will cause the current thread to block until the
operation completes, a timeout occurs or the post is canceled. During
the operation, the OnProgress event will fire periodically,
enabling the application to update any user interface objects such as
a progress bar.