Cloud Firestore REST API-创建文档时出现400错误请求

时间:2019-06-16 01:02:54

标签: firebase google-cloud-firestore

我正在Unity(C#)中使用Cloud Firestore REST API并尝试创建文档。但是,写入始终失败,错误代码为400。这是我的代码:

string test = "{\"fields\": { \"field1\": {\"stringValue\": \"hello world\"}}}";
using (UnityWebRequest www = UnityWebRequest.Post($"https://firestore.googleapis.com/v1/projects/{PROJECT_ID}/databases/(default)/documents/{path}", test))
    {
    yield return www.SendWebRequest();
    if (www.isNetworkError || www.isHttpError)
    {
        Debug.Log(doc.ToJson());
        Debug.Log($"Write failed: {www.error}");
    }
}

奇怪的是,我一直在搞弄API Explorer,并且完全相同的有效载荷在那里工作。网址与资源管理器生成的网址相同,但减去了API密钥,但是添加并不能解决问题。我想念什么?

0 个答案:

没有答案