Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting response with status: 405. Method not allowed for URL with POST in Firebase

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;
    }
like image 268
Didi Avatar asked May 29 '17 12:05

Didi


1 Answers

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.

like image 104
Frank van Puffelen Avatar answered Sep 19 '22 08:09

Frank van Puffelen