wwHTTP::cContentType
less than 1 minute to read

Sets the Content Type for POST data sent to the server. Use the content type if you're posting raw POST buffers for data like JSON (application/json) or XML (text/xml) or raw binary data.

If you're posting HTML style form data using Url Encode or Multi-Part forms, look at the nHttpPostMode property which allows you to specify key value pairs to build a POST buffer.

If neither nHttpPostMode or cContentType are explicitly set, the default active POST mode is nHttpPostMode=2 which is url encoded form data with a content type of application/x-www-form-urlencoded.

o.cContentType

Remarks

Do not use cContentType in combination with nHttpPostMode - use one or the other.

Use cContentType for raw post buffers like raw JSON or XML via AddPostKey(lvValue). Use nHttpPostMode for url encoded or multi-part, key/value pair form submissions using AddPostkey(lcKey, lvValue).

Example

foxpro
*** Send JSON data to a REST service loHttp = CREATEOBJECT("wwHttp") *** Specify the data sent is JSON loHttp.cContentType = "application/json" *** POST the raw JSON data lcJSON = serializer.Serialize( loData ) loHttp.AddPostKey(lcJson) lcResponse = loHttp.HttpGet(lcUrl)

See also:

West Wind Web Connection | wwHTTP::nhttppostmode | wwHTTP::AddPostFile |

© West Wind Technologies, 1996-2024 • Updated: 06/07/20
Comment or report problem with topic