Deleting data within Firebase database through use of a C# application
In this post we will go through deleting data in Firebase using C#, the following will flush the entire database project of all its data. A way in which this could be implemented would be a reset for an application. To begin with we will go through the header files being used. The most important is System.Net which enables the ability for web requests.
using System.Windows.Forms;
using System.Net;
In the next section we are providing the URL of our database project. This should be made available online, simply copy it in. Once copied it is important you add /.Json to the end of the URL. The request method is set to DELETE and the content type is defined.
var request =WebRequest.CreateHttp("https://Projectname.firebaseio.com/.json");
request.Method = "DELETE";
request.ContentType = "application/json";
var response = request.GetResponse();
Below can be seen the code in its entirety.
using System.Windows.Forms;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var request = WebRequest.CreateHttp("https://Projectname.firebaseio.com/.json");
request.Method = "DELETE";
request.ContentType = "application/json";
var response = request.GetResponse();
}
}