cHttpClient Properties Reference
📝 Request Data Properties
RequestDataJson
Sets JSON format request body data.
Public RequestDataJson As New cJsonDescription: When this property is set and Content-Type is JSON, the request body will be automatically serialized to JSON string.
Example:
Dim http As New cHttpClient
Dim json As New cJson
json.AddItem "username", "admin"
json.AddItem "password", "123456"
Set http.RequestDataJson = json
http.SendPost("https://api.example.com/login")RequestDataForm
Sets Form format request body data (form data).
Public RequestDataForm As New Scripting.DictionaryDescription: Suitable for application/x-www-form-urlencoded type requests.
Example:
Dim http As New cHttpClient
http.RequestDataForm("username") = "admin"
http.RequestDataForm("password") = "123456"
http.RequestDataForm("remember") = "true"
http.SendPost("https://api.example.com/login")RequestDataQuery
Sets URL query parameters.
Public RequestDataQuery As New Scripting.DictionaryDescription: Will be automatically appended to URL when sending request.
Example:
Dim http As New cHttpClient
http.RequestDataQuery("page") = "1"
http.RequestDataQuery("limit") = "20"
http.RequestDataQuery("sort") = "desc"
' Final URL: https://api.example.com/users?page=1&limit=20&sort=desc
http.SendGet("https://api.example.com/users")RequestDataBody
Deprecated - Please use RequestDataForm instead.
📋 Request Configuration Properties
RequestHeaders
Sets custom request headers.
Public RequestHeaders As New Scripting.DictionaryExample:
Dim http As New cHttpClient
http.RequestHeaders("Authorization") = "Bearer token123"
http.RequestHeaders("X-Custom-Header") = "custom-value"
http.RequestHeaders("User-Agent") = "MyApp/1.0"
http.SendGet("https://api.example.com/protected")RequestContentType
Sets request content type.
Public RequestContentType As StringCommon Values:
application/json- JSON dataapplication/x-www-form-urlencoded- Form data (default)multipart/form-data- File uploadtext/plain- Plain texttext/html- HTML content
Example:
Dim http As New cHttpClient
http.RequestContentType = "application/json"
' Or use convenience method
http.SetRequestContentType(ReqContentTypeJson)RequestChartSet
Sets request encoding.
Public RequestChartSet As StringDefault: utf-8
Description: Affects request body encoding. When set to UTF-8, will use UTF-8 encoding.
RequestTimeOut
Sets request timeout (seconds).
Public RequestTimeOut As LongDefault: 30 seconds
Description: Only used in sync request mode.
Example:
Dim http As New cHttpClient
http.RequestTimeOut = 60 ' 60 seconds timeout
http.SendGet("https://api.example.com/slow-api")📥 Response Data Properties
ResponseRaw
Cached raw response content.
Public ResponseRaw As VariantResponseHeaders
Response headers dictionary.
Public ResponseHeaders As New Scripting.DictionaryExample:
Dim http As New cHttpClient
http.SendGet("https://api.example.com")
' Get response header
If http.ResponseHeaders.Exists("Content-Type") Then
Debug.Print "Content-Type: " & http.ResponseHeaders("Content-Type")
End If
' Iterate all response headers
Dim key As Variant
For Each key In http.ResponseHeaders.Keys
Debug.Print key & ": " & http.ResponseHeaders(key)
NextCookies
Parsed Cookies dictionary.
Public Cookies As New Scripting.DictionaryDescription: Auto parsed from response header Set-Cookie.
Example:
Dim http As New cHttpClient
http.SendGet("https://api.example.com/login")
' Get Cookie
If http.Cookies.Exists("session_id") Then
Debug.Print "Session ID: " & http.Cookies("session_id")
End If
' Carry Cookie in next request
http.SetCookies("session_id=" & http.Cookies("session_id"))
http.SendGet("https://api.example.com/profile")⚙️ Debug Properties
DebugStart
Enables debug mode.
Public DebugStart As BooleanDescription: After setting to True, DebugInfo property will be populated after request completes.
Example:
Dim http As New cHttpClient
http.DebugStart = True
On Error Resume Next
http.SendGet("https://api.example.com")
' View debug info
If http.DebugInfo.HasKey("Error") Then
Debug.Print "Error: " & http.DebugInfo.GetItem("Error").GetItem("Description")
End IfLastError
Last error message.
Public LastError As StringExample:
Dim http As New cHttpClient
Dim success As Boolean
On Error Resume Next
success = http.SendGet("https://invalid-url").ReturnText() <> ""
If Not success Then
Debug.Print "Request failed: " & http.LastError
End IfLast Updated: 2026-05-17