Skip to content

Instantly share code, notes, and snippets.

@renatomb
Created November 8, 2018 18:36
Show Gist options
  • Save renatomb/ba286920180ae674fe676b3b5a00fa03 to your computer and use it in GitHub Desktop.
Save renatomb/ba286920180ae674fe676b3b5a00fa03 to your computer and use it in GitHub Desktop.
Exemplo de uso de CURL via linha de comando linux
#Exemplo de CURL preenchendo campos de formulário com -F
curl -X POST -F 'tipo_cnpj=dest' -F 'txtCnpj=99999999999’ -F 'tipo_pesquisa=nf' -F 'txtNumDoc=99999’ http://transportadora.local/jamef/ocorrenciaViagem.do
#Exemplo de CURL enviando conteúdo em json e modificando headers
curl --request POST "http://interno.local/json_decode.php" --header "Content-Type: application/json" --header "MerchantId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --header "MerchantKey: 0123456789012345678901234567890123456789" --header "RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --data '{"MerchantOrderId":"2014111703","Customer":{"Name":"Comprador crédito simples"},"Payment":{"Type":"CreditCard","Amount":15700,"Installments":1,"SoftDescriptor":"123456789ABCD","CreditCard":{"CardNumber":"4500000000000001”,”Holder":"Teste Holder","ExpirationDate":"12/2030","SecurityCode":"123","Brand":"Visa"}}}' --verbose
curl --request POST "http://sandbox.local/try_json/" --header "Content-Type: application/json" --header "DEVICE_ID: 0123456789012345678901234567890123456789" --header "USRAPP_ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --data '{"usuarioapp":{"cpf":"00000000000","nome":"Nome do fulano","apelido":"Fulano","email":"email@dominio.com","senha":"123456","token_fb":"fh30f28744hg240784gh24","nascimento":"1982-07-08","sexo":"M","ddd":84,"telefone”:999999999,”recebe_sms":1}}' --verbose
#Exemplo de curl com parâmetros com -d
curl -d "crm=4306&uf=RN" "http://cfm.local/index.php?option=com_medicos&dadosDoMedico=true" --verbose
#Exemplo de curl com múltiplas linhas para melhor visualização
curl --request POST "https://sandbox.local/try_json/" \
--header "Content-Type: application/json" \
--header "APPOS: Android" \
--header "APPVER: 0.0.1" \
--header "APPID: 98765432109876543210" \
--header "DEVICEID: 0123456789012345678901234567890123456789" \
--header "USRAPPID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
--data '{"usuarioapp":{"cpf":"00000000000","nome":"Nome do fulano","apelido":"Fulano","email":"email@dominio.com","senha":"123456","token_fb":"fh30f28744hg240784gh24","nascimento":"1982-07-08","sexo":"M","ddd":84,"telefone”:999999999,”recebe_sms":1}}' --verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment