Let's talk about widely used HTTP request methods and how to test them.

In this thread, we will cover:

- GET
- POST
- PUT
- DELETE

πŸ§΅πŸ‘‡πŸ»
πŸ“Œ GET

The GET method is the widely used request method. It is used to get the desired resources from the server.

For example, making a request to the /posts endpoint will return all the available posts.
One thing to note here is that we have used plural noun (/posts) for URL naming.

Using plural nouns for naming URLs is the best practice. It simply reduces the confusion about whether there are one or more posts in the resource collection. Using plural nouns for naming URLs is the best practice.
The GET method is safe, idempotent, and cacheable.

It doesn't affect the state of the server even after continuous calls. Also, we can cache the response of GET requests.
Here are a few points you need to validate for GET requests while creating tests for an API

- Server should return a 200 OK status code on a successful request
- Validate all endpoints and ensure they are returning desired data
πŸ“Œ POST

The POST request is used to submit the information to the server. As we're submitting data, the POST request often changes the state of the server.
As POST request change the state of the server, it is not safe.

A POST request is not idempotent because successive POST calls may have additional effects on the server.
POST request is the second most common and widely used HTTP request method.

Here are some points you should consider while creating API tests

- 201 status code on a successful POST request
- Ensure data was saved correctly with a GET request
πŸ“Œ PUT

The PUT request is used whenever you need to change the resource, which is already a part of resource collection.
The PUT request is idempotent, unlike POST. Successive PUT calls will always produce the same result.

But it is neither safe nor cacheable.
Ensure the following things when you create API tests for PUT requests

- Correct status codes are 200, 201, and 204
- Check idempotent characteristics by calling PUT methods successively
- Ensure the updated resource with the help of GET request
πŸ“Œ DELETE

As the name says, the DELETE request is used to delete the specified resource. It requests that the origin server delete the resource identified by the Request-URL.
The DELETE request is idempotent but neither safe nor cacheable.
Steps for creating a test case for the DELETE method would look like this πŸ‘‡πŸ»

- Create a resource using POST request. Let's say /posts
- Delete the created resources using /posts/id
- Ensure the 404 status with GET request

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with RapidAPI

RapidAPI Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Rapid_API

2 Nov
Best practices for designing REST APIs.

πŸ§΅πŸ‘‡πŸ»
The abbreviation REST stands for "REpresentational State Transfer".

REST APIs are used to call resources and allow the software to communicate based on standardized principles, properties, and constraints.
1️⃣ Correct status codes

When developing REST APIs, make sure you use the HTTP status code. This helps your user to know if the request they have made is successful or not.
Read 10 tweets
2 Nov
We always believe in project-based learning. πŸš€

Check out these 11 excellent API-based web development projects you can build using RapidAPI.

Thread πŸ§΅πŸ‘‡πŸ»
1️⃣ Build and sell your own API $$$

- In this video, you'll learn how to make a profitable API and sell it on the RapidAPI Hub.

πŸ”—
2️⃣ Travel Advisor App

- A great tutorial on building and deploying a Google Maps Travel Companion App using a free API available on RapidAPI.

πŸ”—
Read 12 tweets
1 Nov
Here are 20 excellent APIs that can fulfill all your requirements of building a Machine Learning model.

Including voice and facial recognition, text analysis, spam filters APIs, and much more.

Thread πŸ§΅πŸ‘‡πŸ»
1️⃣ Sentiment Analysis

- Enter a string to check the positive or negative tone.

πŸ”— RapidAPI.com/twinword/api/s…

πŸ“ˆ Popularity: 9.6/10
πŸ•› Latency: 342ms
βœ… Service Level: 100%
2️⃣ OOPSpam Spam Filter

- OOPSpam Anti-Spam API helps you better identify spam content for contact forms, comment systems, blogs, live chat, etc.

πŸ”— RapidAPI.com/oopspam/api/oo…

πŸ“ˆ Popularity: 9.3/10
πŸ•› Latency: 351ms
βœ… Service Level: 100%
Read 22 tweets
29 Oct
Introduction to CORS

CORS is an HTTP-based mechanism that lets you request data from one URL to a different URL.

Let's talk about it in a bit more detail. πŸ§΅πŸ‘‡πŸ»
CORS stands for Cross-Origin Resource Sharing.

Half of the definition is clear by the abbreviation. CORS allows a server to share resources with browsers having different origins.
Let's try to understand cross-origin requests via an example:

Suppose you're making an HTTP request from "a .com" to "b .com". That's a cross-origin request.
Read 10 tweets
29 Oct
Everything you need to know about HTTP-based systems.

It is a communication protocol that establishes the connection between web browsers and web servers.

Thread πŸ§΅πŸ‘‡πŸ»
HTTP is entirely based on the client-server model, where the client initiates the request then waits until it receives a response from the server.
Typically, there are 3 main components in the HTTP-based system. πŸ‘‡πŸ» Components of an HTTP-based system.
Read 18 tweets
28 Oct
Here are Top 5 Image Search and Image Recognition APIs you can use in your next project.

Thread πŸ§΅πŸ‘‡πŸ»
1️⃣ Imgur

- Imgur is an online image sharing and image hosting service. Imgur’s API exposes the entire Imgur infrastructure via a standardized programmatic interface.

πŸ”— RapidAPI.com/imgur/api/imgu…

πŸ“ˆ Popularity: 9.9/10
πŸ•› Latency: 251ms
βœ… Service Level: 100%
2️⃣ Web Search

- Billions of webpages, images and news with a single API call.

πŸ”— RapidAPI.com/contextualwebs…

πŸ“ˆ Popularity: 9.8/10
πŸ•› Latency: 1,634ms
βœ… Service Level: 99%
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(