I am trying to POST some data to my Firebase database with REST API. However, I keep getting the error: response with status: 405. Method not allowed for URL: https://myurl.firebaseio.com/data
This is how I use the POST request:
createNewRoute(route){
var url;
var data = {
RouteStartAddress: route.startAddress,
RouteEndAddress : route.endAddress,
RouteStartCord: route.startCord,
RouteEndCord: route.endCord,
DepatureDateTime: route.depatureDateTime,
Seats: route.seats,
Note: route.note,
IsActive: true,
DriverSId: route.userId,
TimeToDist: route.timeToDist,
MetersToDist: route.metersToDist
};
url = this.routeUrl;
var response = this.http.post(url, data).map(res => res.json());
return response;
}
To write to Firebase Database using REST, the URL must end in .json
. So:
url = this.routeUrl + ".json";
From the relevant Firebase documentation:
We can use any Firebase Realtime Database URL as a REST endpoint. All we need to do is append
.json
to the end of the URL and send a request from our favorite HTTPS client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With