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

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