Posted  by  admin

Download Api Tester For Mac 1.1

  1. A TCP listener is amongst the basic yet much needed applications in the toolbox of a network manager. TCP Port Listener Tool is a nifty software utility that can create a local listener for any.
  2. Internet connection measurement for developers. Speedtest CLI brings the trusted technology and global server network behind Speedtest to the command line. Built for software developers, system administrators and computer enthusiasts alike, Speedtest CLI is the first official Linux-native Speedtest application backed by Ookla®.

Featured software trials. Red Hat Ansible Automation Platform. Get the right foundation for operating automation across your organization. Start your free 60-day trial. Red Hat Enterprise Linux. Run your critical workloads on a stable, high-performance, open-source platform. Start your free 30-day trial. Red Hat OpenShift.

Download

(P)Codever is an open source bookmarks and snippets manager for developers & co. See our How To guides to help you get started. Public bookmarks repo on Github -

If you want to quickly test your REST api from the command line, you can use curl. In this post I will present how to execute GET, POST, PUT, HEAD, DELETE HTTP Requests against a REST API. For the purpose of this blog post I will be using the REST api that supports www.codever.land. The API is documented with OpenAPI and available for testing in the browser at https://www.codever.land/api/docs/.

  • Introduction
  • CRUD Operations on Bookmarks.dev API

Introduction

In the first part of the blog post I will do a brief introduction to curl and what it can do (HTTP requests with options). In the second part I will show examples with different HTTP operations from bookmarks.dev-api.

What is curl?

Curl is a command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, HTTP/2, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos…), file transfer resume, proxy tunneling and more.

As mentioned, I will be using curl to simulate HEAD, GET, POST, PUT and DELETE request calls against a REST API.

HEAD requests

If you want to check if a resource is serviceable, what kind of headers it provides and other useful meta-information written in response headers, without having to transport the entire content, you can make a HEAD request.

Let’s say I want to see what I would GET when requesting latest public bookmarks. I would issue the following HEAD request with curl:

Request

OR

Curl options

  • -I or --head - fetch the headers only
  • -i, --include - include the HTTP response headers in the output
  • -X, --request - specify a custom request method to use when communicating with the HTTP server (GET, PUT, DELETE&)

Response

Download Api Tester For Mac 1.1

Note the following headers

  • Access-Control-Allow-Headers: Content-Type, Authorization, Location
  • Access-Control-Allow-Methods: POST, GET, PUT, PATCH, DELETE, OPTIONS
  • Access-Control-Allow-Origin: *

in the response.

They’ve been added to support Cross-Origing Resource Sharing (CORS).

GET request

Executing curl with no parameters on a URL (resource) will execute a GET.

Request

which is equivalent with

Response

Note the use of accept: application/json

Curl options

  • -H, --header : customer header to pass to the server

If you want to have it displayed prettier I suggest you use a tool like jq:

Request

Response

If you don’t want the progress meter (first part) shown, you can silent curl:

Request

Response

Curl options

  • -s, --silent : silent or quiet mode. Don’t show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.

An alternative to jq is to use Python if you have it on your machine:

Curl request with multiple headers

All the responses from the api of bookmarks.dev are gzipped.We could ask for the gzipped variant by issuing the following request:

Request

Curl options

  • -v, --verbose : the opposite of --silent, make the operation more talkative

To achieve that you need to simply add another-H option with the corresponding value. In this case you would get some unreadable characters in the content, if you do not redirect the response to a file:

Response

CRUD Operations on Bookmarks.dev API

Those were some basic curl HTTP calls with a few options. Now we will combine them and show examples against a productionready API. For the examples I will use the API running on localhost. It is really easy to setup with Docker-compose ifyou follow the instructions from the Readme file.

The API is protected with Keycloak and bearer token. A way to obtain a bearer token in Keycloak is to enable Direct Access Grants for the client - this corresponds to the Resource Owner Password Credentialsin the OAuth2 Specification. Thus the user’s credentials are sent within form parameters. Of course we can do that with curl too:

Request

The the username and password are from the initial set up.

The response looks something like the following:

With jq is really easy to extract just the access_token:

Request

Response

Curl options

  • -d, --data : (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded.

Create bookmark - POST

Request

Note the Bearer token is reduced here (Bearer eyJhbGciOiJ....) and in the following examples for brevity

Response

Note the location header - it contains the URL of the new created resource

Read created resource - GET

We will read the previously created bookmark by issuing an GET request on the url from the location header

Response

Update created resource - PUT

Request

Response

Delete created resource - DELETE

Request

Response

Note the 204 OK Status showing that everything worked as expected.

Free

Trying to execute the deletion again will result in an 404 resource NOT_FOUND status:

Response

The stacktrace is shown because we are in dev modus

Download Api Tester For Mac 1.1 Software

Conclusion

Download Api Tester For Mac 1.12

I am just scratching the surface in this blog post. Check out the curl docs for furthercapabilities.