PostData

Description

Sends the string or blob data with POST method.

Applies to

HTTPClient object

Syntax

objectname.PostData ( data, bufferSize )

Argument

Description

objectname

The name of the HTTPClient object for which you want to post the data.

data

A string or blob value specifying the data to post.

bufferSize

A long value specifying the buffer size. For the string data, each PowerBuilder character takes up two bytes of storage.


Return value

Integer.

Returns values as follows. If any argument’s value is null, the method returns null.

1 -- Success

-1 -- General error

-2 -- Timed out

Examples

This example request information by sending a string query:

Integer i, li_PackCount, li_rc
String ls_TotalStrData, ls_NextData
Blob lblb_NextData
HttpClient lnv_HttpClient
lnv_HttpClient = Create HttpClient

// Construct a POST request
// Content-Length indicates the total bytes of data being sent
// Each PB character takes up two bytes of storage
lnv_HttpClient.SetRequestHeader("Content-Length", String(Len(ls_TotalStrData)*2))
...
// Start posting data and request information
if lnv_HttpClient.PostDataStart("http://demo.appeon.com/PB/webapi_client/employee/102/photo") = 1 then
 for i = 1 to li_PackCount
  ...
  li_rc = lnv_HttpClient.PostData(ls_NextData, Len(ls_NextData)* 2)
  // li_rc = lnv_HttpClient.PostData(lblb_NextData, 1024)
  if li_rc <> 1 then exit
 next
end if
if li_rc = 1 then
 li_rc = lnv_HttpClient.PostDataEnd()
end if

See also

PostDataStart

PostDataEnd