Using CURL to send JSON requests & listening with an Ubuntu Netcat server
Here I show how to send a CURL request in a binary format containing JSON key/value pairs. On the other end I show how we are using an Ubuntu Netcat server to listen for our JSON key/value pairs..
I created the following key/value pairs to send through. It's just my e-mail a hashed number and the time of day.
Next we go into the terminal on the Macbook locally to use CURL so we can send our key/value pairs.
We explicitly state the source of the file on our desktop and the destination (the Netcat server). The command line is pretty straight forward in that the commands are essentially self-explanatory. You just have to be very specific with telling the computer what you are sending, how to send it and where to send it.
Here I am logged in via SSH to my cloud based Ubuntu Netcat listening server using a local Debian Linux virtual machine. After I sent the JSON POST request as binary data we can view it on the Netcat server. Before we sent our JSON POST we wrote the command "netcat -l 8080" in the terminal which told Netcat to create a listener on port 8080. When it received our request it not only received the data but also logged some information about who sent it. We can see that it was sent with curl as a JSON file via HTTP from a "Host" which is my Macbook Pro.
I created the following key/value pairs to send through. It's just my e-mail a hashed number and the time of day.
This is a collection of JSON key/value pairs we will send . |
CURL is what we are using to send the JSON from the terminal |
Here is a screenshot from the terminal on our cloud based Ubuntu Netcat listening server. |
Comments
Post a Comment