0

I enabled the soft delete feature on a table (as described here). How can I soft delete / mark a row as deleted using the REST API?

The Rest API tells you how to include deleted records in a query statement, but says nothing how to mark one as deleted.

I tried sending an update query, but received:

{ "code":400, "error":"Error: The property '__deleted' can not be set. Properties that begin with a '__' are considered system properties." } 

I also tried using the DELETE method, but that actually deletes the record.

Any help appreciated!

Edit:

@phillipv requested more information: I'm using Swift and the Alamofire framework. But even when I'm using curl like this:

curl -i \ -X DELETE \ -b "ARRAffinity=XXXXX" \ -H "x-zumo-auth: XXXXXXXX" \ -H "x-zumo-application: XXXXXXX" \ "https://myproject.azure-mobile.net/tables/myTable/BB65C071-6425-44BA-BB63-EBF4D9BF37A1" 

The record gets (hard) deleted.

Can it be an issue that I enabled the soft delete feature on an existing table (created in early 2014)? For all tables without the __deleted column there is a button to Enable soft delete. In the relevant table the button is not there, because I enabled the feature and in the columns view the __deleted column is listed.

Edit2:

I just created a new test table, filled it with some sample data and did the exact same DELETE call and the record was only marked as deleted.

Ok, that is fine and works as @phillipv said in the comments. But now a new question arises:

How can I hard-delete a record using the REST API?

2
  • If the setup worked DELETE should mark it soft deleted. Can you update the question to show your config (or at least backend you are using) Commented Jul 25, 2015 at 0:26
  • @phillipv see my edit. If DELETE soft deletes a record, how can I then hard delete a record using the REST API? Commented Jul 25, 2015 at 10:21

1 Answer 1

1

When you enable "soft delete",the "Deleted" field in the row will set to "true" and the record no longer returned from the mobile service(instead of deleting the record permanently). If you not enable "soft delete", the record will deleted permanently from database. This soft delete feature is to restrict your client apps from deleting/flushing any record/table completely. The traces will be there in the "Deleted" column. :-)

And you don't need to specify "_Deleted" column explicitly. If you check the API controller, you could see the delete operation is handled by

 public Task DeleteYourTableName(string id) { return DeleteAsync(id); } 

So when you pass an 'Id' to delete, The above action knows that the request is to delete the record with the Id provided. If soft delete enabled,'Deleted' field set to true, else deletes the entire row. Which is handled internally by mobile service framework.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.