使用PATCH修改Firebase实时数据库中的数据时遇到问题

时间:2019-10-26 12:27:57

标签: rest firebase-realtime-database

我打算实现使用C编译器在Firebase Realtime Database中写入数据。我使用此PATCH修改值,如下所示。我已请求,但响应出现错误。我可以知道如何纠正此错误吗?

PATCH /.json HTTP/1.1
Host: minmin-68c89.firebaseio.com
Accept: */*
{"dir":"1"}


HTTP/1.1 400 Bad Request
Server: nginx
Date: Sat, 26 Oct 2019 12:04:48 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 36
Connection: keep-alive
Access-Control-Allow-Origin: *
Cache-Control: no-cache
Strict-Transport-Security: max-age=31556926; includeSubDomains; preload

{
   "error" : "No data supplied."
                                }
                                 ATCH /.json HTTP/1.1
Host: minmin-68c89.firebaseio.com
Accept: */*
{"dir":"1"}

1 个答案:

答案 0 :(得分:0)

据我所知,您需要在标题和请求正文之间留空行。

还可以考虑添加一个content-type标头。

通过快速curl测试,我做了:

PATCH /users/jack/name/.json HTTP/1.1
Host: PROJECT_ID.firebaseio.com
User-Agent: curl/7.54.0
Accept: */*
Content-Length: 16
Content-Type: application/x-www-form-urlencoded

{"last":"Jones"}