Web Connection
cURL -> wwHTTP
Gravatar is a globally recognized avatar based on your email address. cURL -> wwHTTP
  Vincent H.
  All
  Dec 28, 2021 @ 12:38am

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

Gravatar is a globally recognized avatar based on your email address. re: cURL -> wwHTTP
  Vincent H.
  Vincent H.
  Dec 28, 2021 @ 05:37am

I've found !

You have to surround the expression with braces, like this:

.AddPostKey ("", '{"stream": "PD94bW ..."}')   && Without "", this does not work !
Gravatar is a globally recognized avatar based on your email address. re: cURL -> wwHTTP
  Rick Strahl
  Vincent H.
  Dec 28, 2021 @ 01:19pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: cURL -> wwHTTP
  Vincent H.
  Vincent H.
  Dec 29, 2021 @ 05:57am

Thanks Rick, I'm going to upgrade ...

Happy New Year

© 1996-2022