Help Libcurl or Clarunext

Hi, I need some help.

I’m having difficulty setting up with libcur the command line, to use in clarion.

curl https://sandbox.mercos.com/api/v1/clientes --include --request PUT --header “Content-Type: application/json” --header "ApplicationToken: e00bf526-0196-11eb-94ad-d20 “–header” CompanyToken: ea69b414-0195-11eb-aec6-0e3 “–data-binary” @D:\send\0000000041.json “–output” D:\return\0000000041-ret.txt "

You probably have a code which doesn’t work as expected?

Hi, part is resolved to work.
To receive the json file I used the process below:

LibcurlClarion routine
DATE
curl TCurlHttpClass
res CURLcode
qLONG Index, AUTO
respBuffer &IDynStr

CODE
postdata = ‘D:\send\0000000041.json’
filetoStore = ‘D:\return\0000000041-ret.txt’
httpVerbContentType = ‘application/json’
respBuffer &= NewDynStr()

curl.Init()
curl.FreeHttpHeaders()
curl.AddHttpHeader('Content-Type: '& httpVerbContentType)
curl.AddHttpHeader('ApplicationToken: '& glo:tokensolver)
curl.AddHttpHeader('CompanyToken: '& xemp:token)
res = curl.SetHttpHeaders()
    
CASE httpVerbMethod
OF HttpVerb:GET
    curl.SetCustomRequest('GET')
OF HttpVerb:PUT
    curl.SetCustomRequest('PUT')
OF HttpVerb:POST
    curl.SetCustomRequest('POST')
END

curl.SetHttpGET(TRUE)
curl.SetSSLVerifyHost(false) ! do not verify host name
curl.SetSSLVerifyPeer(false) ! verify peer

CASE httpVerbMethod
OF HttpVerb:GET
    res = curl.SendRequest(httpWebAddress, requestParameters, filetoStore)
    ! GET request worked perfectly, I received the response file
OF HttpVerb:PUT OROF HttpVerb:POST
    ! Here I am in doubt, which command do I use to send a json to the api server?
    ! I need the server response api for information.
END

You can get file content and pass it as post parameter:

fContents                       &STRING

  fContents &= curl::GetFileContents('D:\send\0000000041.json')
  res = curl.SendRequest(httpWebAddress, fContents, filetoStore)
  !- free memory
  DISPOSE(fContents)