Connected successfully



C# Application to Firebase Database - Deleting Data





In this post we will go through very quickly as to how you can go about deleting data in Googles Firebase using C#, the code presented in the following essentially flushes the entire database or whichever project you may have the web request pointing towards. A great way in which this could be implemented would be to have it as an event for when a button is pressed. The button could for example be a reset for an application your building although not needed for all it is useful. This article will be short not because we dont care but because it is clear what needs to be done. In the previous articles we see that variables are declared and buffered before being sent off for insert or update. However in this example there is no need to declare any variables. The word POST or PATCH is simply being replaced by DELETE. Not sure what we mean by POST and/or PATCH?

Please also note there is no database authentication being used in this example
If however you are wanting to have some form of authentication added to your project check out the below
Authenticating Your C# Application with the Firebase Database


Be sure to have a read up on some of the other posts we have as you may find them of extreme use. Especially if wanting to remove those random base-64 keys being generated when inserting and updating data. Also find out how to retrieve specific children nodes.The list for which can be found below:
Inserting data in to the Firebase database
Updating data in the Firebase database
Retrieving all data from the Firebase database
Inserting Individual parent and child nodes in to the Firebase database
Removing random base-64 keys from the parent nodes within the Firebase database
Retrieving Individual parent and child nodes from the Firebase database



We will now proceed to the code, to begin with we will go through the header files being used



The first header we see is System.Windows.Form which is not needed to carry out functionality although was being used in this example for another project we may be posting which is where we go about triggering these events when buttons have been pressed. If wanting to see this please leave us a message on the Contact page letting us know. The second head we see being use is System.Net which is a requirement in order for us to be able to make the web request.





Here we are moving on to providing a URL, the URL of your database should be made available online simply copy and paste it. Once copy and pasted it is EXTREMELY important you add /.Json to the end of your URL. If you were then to copy and paste this with/.Json at the end of your URL you will see the Json tree in its entirety and you may find it of interest as it will help you get your head around it all. In the second line we see the request method being set to DELETE finally a term we SQL users understand. The content type is then set and a response variable is then declared. Please be careful with this function if your database has already been populated with data you may need as it will remove it. It would be a good idea to create a new project and populate with dummy data. Rather safe than sorry!

Below can be seen the code in its entirety for those who may be interested in exploring for themselves. Please if you have any questions or suggestions click here. Also go ahead and subscribe to our Youtube channel, follow us on Instagram or even subscribe to our mailing list. Please also remember a form was included in this example although not used directly

Be sure to have a read up on some of the other posts we have as you may find them of extreme use. Especially if wanting to remove those random base-64 keys being generated when inserting and updating data. Also find out how to retrieve specific children nodes.The list for which can be found below:
Inserting data in to the Firebase database
Updating data in the Firebase database
Retrieving all data from the Firebase database
Inserting Individual parent and child nodes in to the Firebase database
Removing random base-64 keys from the parent nodes within the Firebase database
Retrieving Individual parent and child nodes from the Firebase database