Sobes.tech
Junior — Middle

What are non-idempotent HTTP requests and how do they differ from idempotent ones?

sobes.tech AI

Answer from AI

Idempotent HTTP requests are those that, when repeated with the same parameters, do not change the server's state after the first call. That is, regardless of how many times you send such a request, the result will be the same, and the server will not create additional changes.

Examples of idempotent methods: GET, PUT, DELETE.

Non-idempotent HTTP requests are requests that, when repeated, can lead to a change in the server's state each time. For example, a POST request that creates a new record will create multiple records if sent repeatedly.

Difference:

  • Idempotent: repeated requests do not change the result (e.g., updating a resource with the same data).
  • Non-idempotent: repeated requests lead to new changes (e.g., creating new records).

This is important to consider when designing APIs and automating testing to avoid unwanted side effects.

What are non-idempotent HTTP requests and how do they… - sobes.tech