How to use cURL and Chrome Postman

How to use curl and postman

Intent

As the growing of web applications which base on HTTP scripting. The needed of checking and getting the information from the web quickly or post, upload data to web server are very frequent tasks in web development. What’s the best way if we want to quickly do all kinds of URL manipulations and transfers. The answer is cURL and Postman. This article will help you how to use cURL  and Postman in today web development.

cURL Overview

cURL (Client for URLs) can transfer data from or to a web server by using these supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). Don’t worry about those protocols we will focus, that’s just an overview about cURL. What we need is how to use it.

To run cURL command line on window you need to download it here or the easier way is install git then open git bash to run cURL.

How to use cURL command

  • Get data from a URL with GET method, then you will get the json data response from github
    curl https://api.github.com
    
  • Use curl request and specify the HTTP method we will use (POST, PUT or DELETE), GET method will be default if we don’t specify
    curl http://target.url/todo/1 -XPUT
  • Send data in the request
    curl http://target.url/edit/task -XPUT  -d "name=update_first_task"
  • Update data with the basic authentication
    curl http://user:password@target.url/user/1 -XPUT -d "name=newname"
    # or
    curl -u username:password http://target.url/user/1 -XPUT -d "name=newname"
    
  • Get the information and store to a file
    curl https://api.github.com > api.log
    # or
    curl -o manual.html http://curl.haxx.se/docs/manpage.html
    
  • Download a file or directory from FTP server
    curl -u ftpuser:ftppass -O ftp://ftp_server/backup_folder/backup.zip
    # or
    curl -u ftpuser:ftppass -O ftp://ftp_server/backup_folder/
    
  • Send mail by using SMTP Protocol
    curl --mail-from test_mail@example.com --mail-rcpt receiver@example.com smtp://mailserver.com
    
  • There are many more examples of cURL command, if you want to know more detail, just run
    curl --help
    

What is Chrome Postman

Postman is a tool to send HTTP requests to a REST-based service. This article will show you how to install the Chrome extension Postman and how to use it.

How to install Chrome Postman

Open this Postman install link then simply install it. After you have installed Postman, start the app by going to Apps bookmark and you will see the Postman – REST Client.

How to use Chrome Postman – REST Client

This is really amazing tool, everything are visualization

  • It supports many method such as GET, POST, PUT, DELETE, COPY ...
  • You can click Headers and choose the header content type and the value pair
  • After fill in all parameter click send to see the result

How to use curl and postman

Conclusion

That’s how to use cURL and Chrome Postman, they are two very useful way to quickly make a HTTP request to the webserver. With cURL and Chrome Postman you can develop the REST API quickly and coding with more fun.

Related Post

2 Comments

  • CD

    February 15, 2016

    You really need an editor. I cannot understand that first paragraph at all (it makes absolutely no sense), so I can’t be bothered with the rest of the article.

    Reply
    • Web Technologies

      February 15, 2016

      Thank for your comment, I will optimize it. Do you have any suggestion

      Reply

Leave a Reply