CURL equivalent

Questions and answers on developing, deploying and using plugins and JavaBeans

CURL equivalent

Postby Roberto Blasco » Wed Jul 13, 2016 2:05 pm

Hi all.

How can I translate this curl command to Servoy with the http.plugin ?

Code: Select all
curl -X PUT --data-binary my_file.pdf http://localhost:8080 --header "Content-type: application/pdf"


or
Code: Select all
curl -T my_file.pdf http://localhost:8080 --header "Accept: text/plain"


Thanks in advance.

Best regards. Roberto Blasco
Un saludo. Roberto.

Madrid - Spain
Tfno: (+34) 625653066
E-mail: [email protected]
User avatar
Roberto Blasco
007
 
Posts: 341
Joined: Tue Apr 08, 2008 7:18 pm
Location: Madrid / Spain

Re: CURL equivalent

Postby Roberto Blasco » Wed Jul 13, 2016 10:24 pm

I am going to answer to myself :D

Code: Select all
/** @type {plugins.file.JSFile} */
var jsfile = plugins.file.createFile(filename_path);
   
var client = plugins.http.createNewHttpClient();
var request = client.createPutRequest("http://localhost:8080");
request.addHeader("Content-type","application/pdf");     // In this case is a pdf file
request.setFile(jsfile);
var response = request.executeRequest();


P.S.: Thanks to Adelo Herrero for his help !!!!
Un saludo. Roberto.

Madrid - Spain
Tfno: (+34) 625653066
E-mail: [email protected]
User avatar
Roberto Blasco
007
 
Posts: 341
Joined: Tue Apr 08, 2008 7:18 pm
Location: Madrid / Spain

Re: CURL equivalent

Postby fmhuertas » Wed Mar 08, 2017 9:15 pm

Hi all.

How can I translate this curl command to Servoy with the plugins.http?
Code: Select all
curl --insecure --progress-bar -X POST -F 'number=9999999999' -F 'text=texto prueba' https://IP:44443/EnvioSMS.php


Best regards. Fernando Huertas.
fmhuertas
 
Posts: 1
Joined: Wed Mar 08, 2017 6:12 pm

Re: CURL equivalent

Postby juan.cristobo » Thu Mar 09, 2017 12:14 pm

I'm not sure what -F option is, but have you tried this?

Code: Select all
var client = plugins.http.createNewHttpClient();
var request = client.createPostRequest("https://IP:44443/EnvioSMS.php");
request.addHeader("Content-type","multipart/form-data");
request.addParameter('number', '9999999999');
request.addParameter('text', 'texto prueba');
var response = request.executeRequest();
Juan
Madrid (Spain)

Servoy 7.4.x - MySQL / SQL Server 2008-2016
Windows 10 Pro
juan.cristobo
 
Posts: 178
Joined: Thu Apr 19, 2012 9:12 am

Re: CURL equivalent

Postby jeffrey.vandenhondel » Thu Jul 27, 2017 1:42 pm

And this on

Code: Select all
curl -H "Content-Type: multipart/form-data" -F "[email protected]" -H
"Authorization: Bearer 88ds08fsd8fsdf" -X POST
http://example.com


Autorization part i know but its the form-data part i dont understand with the plugin.http.
jeffrey.vandenhondel
 
Posts: 23
Joined: Thu Jul 28, 2016 9:05 am


Return to Plugins and Beans

Who is online

Users browsing this forum: Bing [Bot] and 4 guests

cron