2017-05-29 116 views
0

我想用REST API将一些数据发布到我的Firebase数据库。不过,我不断收到错误:response with status: 405. Method not allowed for URL: https://myurl.firebaseio.com/data获取状态响应:405.方法不允许在Firebase中使用POST POST URL

这是我如何使用POST请求:

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; 
    } 

回答

3

要使用REST写火力地堡数据库,URL必须在.json结束。所以:

url = this.routeUrl + ".json"; 

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.

相关问题