Web Connection
cURL -> wwHTTP
Hi Rick,
I still have this problem of translating a cURL request to send JSON data (in base24)
curl --location --request POST 'http://127.0.0.1:xxxx/.../prevalider' \
--header 'Content-Type: application / json' \
--data-raw '{
"stream": "PD94bW ..."} '
loHTTP = CREATEOBJECT ('wwHTTP')
WITH loHTTP
.nConnectTimeOut = 60
.lUseLargePostBuffer = .T.
.addheader ("Content-Type", "application / json")
.AddPostKey ("stream", Base64 (Mpop))
...
This request does not pass (invalid parameters).
How to reproduce the above cURL request?
Thanks in advance
I've found !
You have to surround the expression with braces, like this:
.AddPostKey ("", '{"stream": "PD94bW ..."}') && Without "", this does not work !
How old is this version you are using? Any reasonably recent version does not require the first parameter to provide a full post buffer.
This must be v5 or perhaps even older.
This should be the correct syntax:
.cContentType = "application/json"
.AddPostKey ('{"stream": "PD94bW ..."}')
See wwHttp::AddPostKey() documentation for examples of how AddPostKey()
can be used.
+++ Rick ---