Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7748779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:52:16+00:00 2026-06-01T10:52:16+00:00

Imagine a web-application storing some data-resource with some id which stores three attachment (e.g.

  • 0

Imagine a web-application storing some data-resource with some id which stores three attachment (e.g. pdf) per datum.

The URL scheme is

data/{id}/attachment1
data/{id}/attachment2
data/{id}/attachment3

An RESTful API exists for the attachments providing GET/PUT/DELETE operations implementing CRUD operations on the server side.

Letting the id be 123, I would like to perform an operation where

  • attachment1 is replaced by a new attachment (such that GET
    file/123/attachment1
    returns the a new attachment)
  • attachment2 is deleted (such that that GET file/123/attachment2 returns 404)
  • attachment3 remains unchanged.

The update should be atomic – the complete update is performed by the server or nothing at all.

Applying a simple PUT file/123/attachment1 and DELETE file/123/attachment2 is not atomic, since the client could crash after the PUT and the server has no hint that he should do a rollback in this case.

So how do I implement the operation in a RESTful way?

I’ve thought of two solutions but they both do not seem to be 100% RESTful:

  • Use PATCH (could be PUT, but PATCH better reflects the semantics of
    an partial update) with multipart/form-data on data/123: The
    multipart/form-data is a sequence of entities consisting of a new
    “application/pdf” associated with the field “attachment1” and
    something which would represent a null-value to denote deletion of
    attachment2.

While this ensures atomicity, I doubt this is RESTful since i overload the PATCH method using different parameter lists, which violates the uniform-interface constraint.

  • Use a resource representing a transaction. I could POST the data id 123
    to a transaction-URL which would create a transaction resource
    representing a copy of the current state of the data-resource stored
    on the server, e.g. transaction/data/123. Now i can call PUT and
    DELETE on the attachments of this temporary resource (e.g. DELETE transaction/data/123/attachment2) and communicate
    the commit of this version of the resource to the server via a PUT on
    transaction/data/123. This ensures atomicity while a have to
    implement additional server side logic to deal with multiple clients
    changing the same resource and crashed clients which never committed.

While this seems to be consistent with REST it seems to violate the contraint of statelessness. The state of the transactional resource is not service state but application state, since every transactional resource is associated with a single client.

I’m kind of stuck here, so any ideas would be helpful, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:52:17+00:00Added an answer on June 1, 2026 at 10:52 am

    You want to use the second option, the transaction option.

    What you’re missing is the creation of the transaction:

    POST /transaction
    
    HTTP/1.1 301 Moved Permanently
    Location: /transaction/1234
    

    Now you have a transaction resource that is a first class citizen. You can add to it, delete from it, query to see its current contents, and then finally commit it or delete (i.e. rollback) the transaction.

    While the transaction is in progress, it’s just another resource. There’s no client state here. Anyone can add to this transaction.

    When its all done, the server applies the changes all at once using some internal transaction mechanism that’s out of scope here.

    You can capture things like Etags and if-modified headers in the transaction sub actions so that when they’re all applied, you know that something didn’t change behind your back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine a web application that performs two main functions: Serves data from a file
Imagine a web application written in Ruby on Rails. Part of the state of
Imagine that your web application maintains a hit counter for one or multiple pages
Imagine that you want to develop a non-trivial end-user desktop (not web) application in
I'm designing my database and LINQ To SQL ASP.NET web application. Imagine I have
Imagine a Java client/server ERP application serving up to 100 concurrent users, both web
Imagine you have a web application written in Django and Python 2.65, and MySQL
Imagine we need to pass a a number structured objects to the web application
So imagine I'm building a Multi User Dungeon system using a MVC web application.
I have a 3-columns template in my web application. Imagine that the right-side div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.