Submits the contents of the specified MemoryStream to a resource on the server.
This method returns a Boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false. To get extended error information, check the value of the LastError property.
The PostData method submits the contents of the specified MemoryStream to the web server and returns the result in another MemoryStream object provided by the caller. 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.
When encountering a server error during a request, the PostData method normally returns false, and no data is copied into the caller-provided MemoryStream. The LastError property is updated to reflect the general cause of the failure, allowing the application to handle this error condition appropriately. Additionally, servers may provide further details about the failure, such as XML or JSON formatted data containing specific error codes or diagnostic messages.
To capture this error information, you can utilize the postErrorData option. When this option is enabled, the behavior of PostData changes; it does not return false for server error statuses. Instead, any error data provided in the server's response, regardless of its format, is copied into the MemoryStream object provided by the caller.
HttpClient Class | SocketTools Namespace | HttpClient.PostData Overload List