firebase - Cloud Firestore REST API - 创建文档时出现 400 错误请求
问题描述
我在 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 并且完全相同的有效负载在那里工作。url 与资源管理器生成的相同,减去 API 密钥,但添加并不能解决问题。我错过了什么?
解决方案
推荐阅读
- android - Android导航组件 - 从“任何地方”/基本片段导航?
- gatsby - 盖茨比 - 找不到模块反应
- python - 根据另一个数据帧的值替换数据帧的 NaN
- reactjs - React Native(EXPO)中通用链接中的哈希标记
- ios - UILabel 上的 Swift 动态宽度被破坏
- c# - 无法设置共享 Excel 加载项组图像
- c# - C# | 枚举排序的编译时间检查
- angular - Chart.js 和 Angular 的渐变效果
- android - Android如何让这种“波浪”像自定义设计的布局背景?
- javascript - 我的 smtp 密码包含特殊字符给出错误