Cómo hacer una solicitud de PUT con curl?
¿Cómo pruebo un método RESTful PUT (o DELETE) usando curl?
4 answers
Usando la bandera -X
con el verbo HTTP que quieras:
curl -X PUT -d arg=val -d arg2=val2 localhost:8080
Este ejemplo también usa la bandera -d
para proporcionar argumentos con su solicitud PUT.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-08 21:40:10
Puede utilizar el CARTERO aplicación de Chrome Store.
En una sola línea, el comando curl sería:
A) Si envía datos del formulario:
curl -X PUT -H "Content-Type: multipart/form-data;" -F "key1=val1" "YOUR_URI"
B) Si envía datos sin procesar como json:
curl -X PUT -H "Content-Type: application/json" -d '{"key1":"value"}' "YOUR_URI"
C) Si envía un archivo con una solicitud POST:
curl -X POST "YOUR_URI" -F 'file=@/file-path.csv'
Para la solicitud con otros formatos o para diferentes clientes como java, PHP, puede consultar POSTMAN/comment a continuación.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-23 11:46:08
Un ejemplo puesto siguiendo el comentario de Martin C. Martin:
curl -T filename.txt http://www.example.com/dir/
Con -T
(igual que --upload-file
) curl usará PUT para HTTP.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-21 10:51:16
curl -X PUT -d 'new_value' URL_PATH/key
Donde
X-opción que se utilizará para el comando request
D-opción que se utilizará para poner datos en la url remota
URL_PATH-url remota
New_value-valor que queremos poner a la clave del servidor
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-09-22 10:17:16