# Help Libcurl or Clarunext

**URL:** <https://clarionhub.com/t/help-libcurl-or-clarunext/4196>\
**Category:** questions\
**Created:** [June 1, 2021, 8:02pm UTC](https://clarionhub.com/t/help-libcurl-or-clarunext/4196 "2021-06-01T20:02:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JLHenriques](https://clarionhub.com/user_avatar/clarionhub.com/jlhenriques/32/1688_2.png) [@JLHenriques](https://clarionhub.com/u/JLHenriques)\
**Post date:** [June 1, 2021, 8:02pm UTC](https://clarionhub.com/t/help-libcurl-or-clarunext/4196/1 "2021-06-01T20:02:46Z")

</div>

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](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 "

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [June 1, 2021, 9:10pm UTC](https://clarionhub.com/t/help-libcurl-or-clarunext/4196/2 "2021-06-01T21:10:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JLHenriques](https://clarionhub.com/user_avatar/clarionhub.com/jlhenriques/32/1688_2.png) [@JLHenriques](https://clarionhub.com/u/JLHenriques)\
**Post date:** [June 4, 2021, 7:51pm UTC](https://clarionhub.com/t/help-libcurl-or-clarunext/4196/3 "2021-06-04T19:51:23Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [June 4, 2021, 8:42pm UTC](https://clarionhub.com/t/help-libcurl-or-clarunext/4196/4 "2021-06-04T20:42:24Z")

</div>

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)

```
