Skip to content

HttpPost - cHttpClient

Include: Use System\Http.pkg

Sends a POST request with a required body.

Type: Function

Return data type: HttpStatus, which is an alias for UShort

Parameters

Parameter Type Description
sPath String Relative path or absolute URL.
vBody Variant Request body. Strings are sent as text/plain, UChar[] values are sent as application/octet-stream, and structs/arrays/other Variant values are serialized to JSON as application/json unless sContentType or Content-Type overrides it.
sContentType String Optional content type. When omitted, cHttpClient selects a content type from the body value or uses the existing Content-Type request header.

Syntax

Function HttpPost String sPath Variant vBody {String sContentType} Returns HttpStatus

Call

Get HttpPost of hoObj "/post" vBody to eStatus

Description

Sends POST with a required body and optional content type. See Automatic request body serialization.

Automatic serialization example

Struct HttpDT1
    { Name="username" }
    String sUsername
    { Name="attributes" }
    String[] asAttributes
End_Struct

Struct HttpBinResultDT1
    { Name="origin" }
    String sOrigin
    { Name="url" }
    String sUrl
    { Name="data" }
    String sData
    { Name="json" }
    HttpDT1 oJson
End_Struct
HttpDT1 oUsr oRetUsr
HttpStatus eStatus

Move "demo" to oUsr.sUsername
Move "group1" to oUsr.asAttributes[-1]
Move "group2" to oUsr.asAttributes[-1]

Get HttpPost of hoObj "/post" oUsr to eStatus
Get HttpResponseToDataType of hoObj False "json" to oRetUsr