Author Topic: Curl -F parameter  (Read 583 times)

Mafact

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Curl -F parameter
« on: February 06, 2018, 04:40:53 AM »
Hi,

I'm trying to upload a file but without success...

the Curl command wich is working is

curl \
    -H "X-Software-Company: 08d09a20-1a94-4284-9305-375d46a02914" \
    -F "file=@file.xml" \
    -u <login:password> "https://sandbox-api.codabox.com/v2/peppol/licences/95c359ec-7cee-4eaa-b9ba-a6e07db22f31/upload/"

So I can connect using

   oHttp.SetRequestHeader  "Content-Type", "multipart/form-data"   

   oHttp.Login = cLogin
   oHttp.Password = cPasswd
     
   oReq.ContentType = "multipart/form-data"
   oReq.AddHeader "X-Software-Company", "08d09a20-1a94-4284-9305-375d46a02914"
   oReq.AddHeader "Content-Type", "multipart/form-data"   
   
   oReq.HttpVerb = "POST"
 
  This one seem to not work ( -d param in CURL, not -F )
   oReq.AddParam ("file","file=@file.xml")



   oResp = oHttp.PostUrlEncoded("https://sandbox-api.codabox.com/v2/peppol/licences/95c359ec-7cee-4eaa-b9ba-a6e07db22f31/upload/",oReq)

   success = oHttp.LastMethodSuccess return 1 ok

  The file is never sended !

  Any Idea ?


Chilkat

  • Administrator
  • Full Member
  • *****
  • Posts: 103
  • Karma: +6/-0
    • View Profile
Re: Curl -F parameter
« Reply #1 on: February 06, 2018, 07:01:02 AM »
Use the online tool to generate code from a CURL command:   http://tools.chilkat.io/curl.cshtml

Mafact

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Curl -F parameter
« Reply #2 on: February 06, 2018, 09:39:12 AM »
Thanks,

Will do :)