Skip to content

Instantly share code, notes, and snippets.

@pydawan
Forked from Kartones/CURL-cheatsheet.md
Created September 17, 2019 00:17
Show Gist options
  • Select an option

  • Save pydawan/29908b1d316c5d01018ccfd21a230cda to your computer and use it in GitHub Desktop.

Select an option

Save pydawan/29908b1d316c5d01018ccfd21a230cda to your computer and use it in GitHub Desktop.

Revisions

  1. @Kartones Kartones revised this gist Sep 3, 2019. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions CURL-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,10 @@ curl -i -H 'Accept: application/json' -X POST -F "filename=@/file/path" -F "othe
    ```bash
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"key1":"value1"}' "http://hostname/resource"
    ```
    * POST
    ```bash
    curl -i -X POST -H 'Content-Type: application/x-www-form-urlencoded' --data 'key1=value1&key2=value2' url
    ```
    * "Debugging mode" (without actual content output):
    ```bash
    curl -XGET -vvv http://hostname/resource > dev\null
  2. @kartones-tkt kartones-tkt revised this gist Sep 18, 2017. 1 changed file with 9 additions and 5 deletions.
    14 changes: 9 additions & 5 deletions CURL-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,27 @@
    * XML GET
    ```
    ```bash
    curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET "http://hostname/resource"
    ```
    * JSON GET
    ```
    ```bash
    curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET "http://hostname/resource"
    ```
    * JSON PUT
    ```
    ```bash
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT -d '{"updated_field1":"updated_value1"}' "http://hostname/resourcex"
    ```
    * JSON POST uploading a file
    ```
    ```bash
    curl -i -H 'Accept: application/json' -X POST -F "filename=@/file/path" -F "other_field=its_value" "http://hostname/resource"
    ```
    * JSON DELETE
    ```
    ```bash
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"key1":"value1"}' "http://hostname/resource"
    ```
    * "Debugging mode" (without actual content output):
    ```bash
    curl -XGET -vvv http://hostname/resource > dev\null
    ```

    ### Useful arguments
    * ```-k```: not check SSL certificates
  3. @Kartones Kartones revised this gist Feb 11, 2016. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions CURL-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,8 @@ curl -i -H 'Accept: application/json' -X POST -F "filename=@/file/path" -F "othe
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"key1":"value1"}' "http://hostname/resource"
    ```

    * use ```-k``` to not check SSL certificates
    * use ```-L``` to follow redirects
    * use ```-v``` to get verbose output
    ### Useful arguments
    * ```-k```: not check SSL certificates
    * ```-L```: follow redirects
    * ```-v```: get verbose output
    * ```-V```: get headers at output
  4. @Kartones Kartones revised this gist Jan 23, 2016. 1 changed file with 17 additions and 12 deletions.
    29 changes: 17 additions & 12 deletions CURL-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,23 @@

    ```bash
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT -d '{"table_name":"ojete"}' "http://d.localhost.lan:3000/api/v1/tables/641732/registar/?api_key=xxxx"
    * XML GET
    ```

    ```bash
    curl -i -H 'Accept: application/json' -X POST -F "filename=@/file/path" -F "other_field=its_value" "http://d.localhost.lan:3000/api/v1/tables/642009/registar/?api_key=xxx"
    curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET "http://hostname/resource"
    ```


    ```bash
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"table_name":"untitled_table_2"}' "http://d.localhost.lan:3000/api/v1/tables/642009/registar/?api_key=xxx"
    * JSON GET
    ```
    curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET "http://hostname/resource"
    ```
    * JSON PUT
    ```
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT -d '{"updated_field1":"updated_value1"}' "http://hostname/resourcex"
    ```
    * JSON POST uploading a file
    ```
    curl -i -H 'Accept: application/json' -X POST -F "filename=@/file/path" -F "other_field=its_value" "http://hostname/resource"
    ```
    * JSON DELETE
    ```
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"key1":"value1"}' "http://hostname/resource"
    ```



    * use ```-k``` to not check SSL certificates
    * use ```-L``` to follow redirects
  5. @Kartones Kartones revised this gist Oct 26, 2015. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions CURL-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -3,10 +3,17 @@
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT -d '{"table_name":"ojete"}' "http://d.localhost.lan:3000/api/v1/tables/641732/registar/?api_key=xxxx"
    ```

    ```bash
    curl -i -H 'Accept: application/json' -X POST -F "filename=@/file/path" -F "other_field=its_value" "http://d.localhost.lan:3000/api/v1/tables/642009/registar/?api_key=xxx"
    ```


    ```bash
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"table_name":"untitled_table_2"}' "http://d.localhost.lan:3000/api/v1/tables/642009/registar/?api_key=xxx"
    ```



    * use ```-k``` to not check SSL certificates
    * use ```-L``` to follow redirects
    * use ```-v``` to get verbose output
  6. @Kartones Kartones revised this gist Dec 16, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion CURL-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,5 @@ curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DEL
    ```

    * use ```-k``` to not check SSL certificates
    * use ```-L``` to follow redirects
    * use ```-L``` to follow redirects
    * use ```-v``` to get verbose output
  7. @Kartones Kartones revised this gist Dec 16, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions CURL-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -7,5 +7,5 @@ curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"table_name":"untitled_table_2"}' "http://d.localhost.lan:3000/api/v1/tables/642009/registar/?api_key=xxx"
    ```

    use ```-k``` to not check SSL certificates
    use ```-L``` to follow redirects
    * use ```-k``` to not check SSL certificates
    * use ```-L``` to follow redirects
  8. @Kartones Kartones revised this gist Dec 16, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion CURL-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -7,4 +7,5 @@ curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"table_name":"untitled_table_2"}' "http://d.localhost.lan:3000/api/v1/tables/642009/registar/?api_key=xxx"
    ```

    use ```-k``` to not check SSL certificates
    use ```-k``` to not check SSL certificates
    use ```-L``` to follow redirects
  9. @Kartones Kartones created this gist Jul 23, 2014.
    10 changes: 10 additions & 0 deletions CURL-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@

    ```bash
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT -d '{"table_name":"ojete"}' "http://d.localhost.lan:3000/api/v1/tables/641732/registar/?api_key=xxxx"
    ```

    ```bash
    curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"table_name":"untitled_table_2"}' "http://d.localhost.lan:3000/api/v1/tables/642009/registar/?api_key=xxx"
    ```

    use ```-k``` to not check SSL certificates