How to perform this kind of CURL request on Ruby -
i using api provided web host whom can register new clients , domains. unfortunately don't provide documentation (basically none) , i'm not used curl
they give 1 , superficial example of how create new client, , follows
curl -d "clientetipo=i&clientecpfcnpj=00112135045&clienteempresa=nomeempresa&clientenome=meunome&clienteemail=email@dominio.com.br&clienteemailcobranca=emailcobranca@dominio.com.br&clientesenhapainel=654321&clientefone=555100000000&clientefax=555100000001&clientecep=44587421&clienteendereco=ruanome&clientebairro=meubairro&clientecidade=porto alegre&clienteestado=rs&clientelimitemapeamento=1&clientelimitesubdominio=2&clientelimitemysql=3&clientelimitemssql=1&clientelimitepgsql=1&clientelimitefirebird=1&clientelimiteftpadd=1&clienteunibox=on&clienteacessoftp=on&clienteacessodownloadbackup=on" -k --digest -u usuario:senha -x post https://api.kinghost.net/cliente
how can transform on curl request on ruby keeping parameters informed above?
this must post, wonder how have inform these parameters, query string. , digest thing?
here (untested) example using rest-client might started https://github.com/rest-client/rest-client).
according able find online, rest-client automatically supports digest authentication that curl request doing.
require 'rest-client' response = restclient::request.execute( method: :post, url: 'https://api.kinghost.net/cliente', verify_ssl: false, user: "usuario", password: "senha", headers: { params: { clientetipo: "i", clientecpfcnpj: "00112135045", clienteempresa: "nomeempresa", clientenome: "meunome", clienteemail: "email@dominio.com.br", clienteemailcobranca: "emailcobranca@dominio.com.br", clientesenhapainel: "654321", clientefone: "555100000000", clientefax: "555100000001", clientecep: "44587421", clienteendereco: "ruanome", clientebairro: "meubairro", clientecidade: "porto alegre", clienteestado: "rs", clientelimitemapeamento: "1", clientelimitesubdominio: "2", clientelimitemysql: "3", clientelimitemssql: "1", clientelimitepgsql: "1", clientelimitefirebird: "1", clientelimiteftpadd: "1", clienteunibox: "on", clienteacessoftp: "on", clienteacessodownloadbackup: "on" } } )
Comments
Post a Comment