Delete all items with restful api - rest

I want delete all items in restful api,I already searched but didn't find anything good
I can delete items with id parameter but I need to clear all of them
Are there anyway to delete all of the items, not deleting items with id one by one

Are there anyway to delete all of the items, not deleting items with id one by one
In HTTP, the semantics of a request apply only to the target-uri; so there isn't any way, for example, to craft a DELETE request that targets multiple resources.
But: there's no rule that each and every row in your database has to have its own dedicated resource, or that all changes to a given row in the database must pass through a single specific resource.
For instance, imagine a web page that lets you delete things. It might look like a bit list, with check boxes next to each item. You select the ones you want to get rid of, click the submit button, and a POST request arrives at the server, which looks at the contents of the request and makes the corresponding changes to the database. That is a perfectly normal REST pattern that we've been using on the web for 25 years.

Related

Google Forms - Delete a single response

I use a Google Form to capture membership details of an amateur organisation. When someone leaves, we mark them as LEFT on the form. However, under the new European GDPR legislation, we are required to physically delete details of any member who has left the group. In the latest version, you can delete a single entry by editing the Form and clicking on Responses ---> Individual ---> Delete but when there are a lot of entries, this is unspeakably tedious as you have to scroll through the entire response list to find the ones to be deleted. Is there a script function which will allow me to do this programmatically ?

Redirect in Sharepoint 2010 Event Receiver

I'm looking at some code which has broken the saving of changes of a List item in SP2010. In the constructor of the Event Receiver the HttpContext is being stored as a local variable then in the ItemUpdating at the end a query parameter containing the return url is retrieved and passed the SPUtility.Redirect(...). This has the effect of canceling any changes that were made in the edit form. So following so scenarios I've found online I'm storing the HttpContext as a static class object and redirecting in the ItemUpdated event and edits are now persisted followed by a redirect to where we are expecting.
I have a concern though with storing a specific user's HttpContext as a static on a class which will potentially be hijacked if another user does the same action between the time user 1 sets the context initially and prior to the redirect. User 2 will overwrite the context and there are potential issues.
The only other option I can think of as a quick way out would be to store a static Dictionary where the key is the user id then remove the entry just prior to redirecting so as to not leave stray HttpContext instances leaking.
So looking at the accepted solution from here the first response by servy42 states The fact that it works for a few trivial test cases at first doesn't make it a viable solution. but doesn't suggest a viable solution.
There's another option best approach may be changing Save Button in ribbon such that when clicked, a ECMA script first save your Item, then redirect to other page, or open other page in dialog. suggested further down but is that the only other way to go?
I'm fairly new to SP and just trying to navigate through the wealth of wrong ways of doing things with my limited knowledge, whilst unfortunately being stuck with SP2010.
Any thoughts on how to go about this?
============
Edit: Further info as requested
So there are two sites one say called A which will have a sub site called B. A has a List and adding an item to that list triggers event receivers which creates sub site B and other related stuff. If I modify the B "item" from the SharePoint list of Bs then I don't need to redirect and returning to the list is fine. If I'm looking and a neatly rendered Gantt chart on A listing the Bs the if I edit B after clicking Save we need to come back to A. If I'm on B there's an edit button as well so I want to return to B after editing and clicking save.
So we have the source= appended when we go to the edit screen. From some reading I've done it seems SharePoint will pick that up and redirect. One of the fields on the edit page is the relative url beneath the A site and if that changes then the redirect url will no longer be valid and throw a 404 so we replace the old B sub path with the newly entered value. But we then need code to redirect to the new location.
I am not quite sure whether i understand your requirements correctly. But i will give it a try. Just a quick summary of what i understood (correct me if i am wrong...):
You have a Root Web in a site collection with a list
Each entry in that list corresponds to a subsite which will be created on List Item creation (ER) below the Root Web as a subsite
List items can be edited from both the List in the root web as well as from the subsite it maps to
On editing from the subsite you want to return to the subsite after saving
My approach would be this:
Follow the steps described in this article SP Dialog and List Forms
Open a dialog on the subsite that links to the edit form of the root web.
After saving the user finds himself already where he should be
Hope this helps... Cheers!
Edit: Just read the requirement about changing of url. Create a custom Edit Form which you enhance with some js that passes values back to the origin site -> Parameters in dialogs. You may then react accordingly in the javascript callback and redirect to the new url.

LightSwitch Lists Within Lists

I have a browse screen in LightSwitch Html that lists Requests.
Each of these Requests contains a list of People.
This is a many to many relationship between People and Requests, done using a RequestPerson table.
On the screen I would like to display each Request line with a list of its People.
Request 1
Person1
Person3
Request 2
Person2
Person3
I tried adding a data item of People to the screen, by clicking the addPeople link in the Request data item, and adding it to each Request's row in the list, but this simply creates duplicate lists of the People in the selected row. I want each People list to be a list of People in the Request it belongs to.
Can anyone make any suggestions as to how I can achieve this?
I found the answer here:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/506ea3fc-f352-4858-9983-83f6b865129a/lists-in-lists?prof=required
Needs ajax calls for each sub-list, but it works.

RESTful page needs both GET and PUT?

My web site has a design where a grid of records is shown. For each record the user might edit it (a GET request) or change its status (this should be a PUT). Do I have a way of doing this without using Javascript?
That is, my current options are:
Use Javascript in a link handler to change the request type as needed.
Separate the GET and PUT activities to separate web pages.
Do the status change via a GET and turn a blind eye to REST specifications right here.
Are there other options?
Thanks,
Jerome.
A GET should not have any side-effects and a PUT would replace the whole resource at the location given by the URI. So the former should be a POST. The latter should be as well, unless it does in fact send the whole resource. A POST is possible without Javascript, obviously.

RESTful GET/POST Form Semantics

When I GET from http://example.com/organization/ I get a list of organizations.
When I GET from http://example.com/organization/xyz/ I get the record for the organization xyz.
When I POST form data to http://example.com/organization/ I create a new organization.
What URL should I use to GET a form to fill out to create a new organization via a POST to http://example.com/organization/?
Looking at How to do a RESTful request for an edit form? and other sources, it would seem that I am really looking for a form resource for organizations -- so I should GET that form at something like http://example.com/organization/form/ and POST to http://example.com/organization/ as described above. This seems...untidy though.
Update
tuespetre's comments have me thinking the best way to do this is to have a form resource. The organziation form is provided via a GET to /form/organization/ which is filled out and posted to /organization/.
A form in the sense that you speak of one is not a resource, but a template to gather user input to POST a new resource.
One really 'RESTful way' to do it would be to utilize some Javascript to 'include' that form in the collection page /organizations, either as a hidden 'slide-down' form or maybe a modal dialog that appears when a certain call to action button is pressed. This would make semantic sense for two reasons:
You won't have to have some arbitrary URI being used for the form (which is not really a resource in the sense that your domain objects are), and
the 'create' form is for POSTing to the collection, so it really closely relates to that collection and thus would not be at all out of place to have right there with the collection.
Of course, you will find many opinions on this, but I would rather not have arbitrary URIs that break the established pattern (i.e., you're not getting an organization with an id of 'new', so why have that inconsistency?)
If you're trying to implement it, I've seen it done in different ways and I don't think there's a rule (but there are different patterns/approachs that you could follow or not).
I would make it http://example.com/organization/new/