curl4delphi icon indicating copy to clipboard operation
curl4delphi copied to clipboard

Add a json post request example

Open RodolfoSilva opened this issue 5 years ago • 2 comments

  curl := CurlGet;
  curl.SetUrl('https://empacser.now.sh/api/sync_proxy')
    .SetCustomHeaders(
      CurlGetSlist
        .AddRaw('Content-type: application/json')
        .AddRaw('Accept: */*')
    )
    .SetProxyFromIe
    .SetOpt(CURLOPT_POST, true)
    .SetOpt(CURLOPT_POSTFIELDS, TEncoding.UTF8.GetBytes('{"xyz": 10}'))
    .SetCaFile('curl-ca-bundle.crt')
    .SetUserAgent(ChromeUserAgent)
    .SwitchRecvToString
    .Perform;

RodolfoSilva avatar Mar 16 '20 00:03 RodolfoSilva

Interesting, but should make a fake server too. Or at least utilize some well-known API.

Mercury13 avatar Mar 27 '20 11:03 Mercury13

I think you can use this api:

https://jsonplaceholder.typicode.com/

RodolfoSilva avatar Mar 27 '20 12:03 RodolfoSilva