java - GetStream API 错误:QueryUsers 因错误“缺少请求有效负载”而失败
问题描述
我尝试使用https://getstream.io/chat/docs_rest/#query-users
GET https://....stream-io-api.com/users?api_key=...
但是当我尝试查询用户时出现以下错误:
"code": 4,
"message": "QueryUsers failed with error: \"QueryUsers failed with error: \"QueryUsers failed with error: \"QueryUsers failed with error: \"QueryUsers failed with error: \"QueryUsers failed with error: \"QueryUsers failed with error: \"Missing request payload\"\"\"\"\"\"\"",
"StatusCode": 400,
"duration": "0.00ms",
"more_info": "https://getstream.io/chat/docs/api_errors_response"
}
任何人都可以帮助我如何在此 API 中添加请求有效负载吗?
谢谢!
解决方案
正如 OP 的评论中所述,他们的文档似乎缺少重要信息。您必须将查询参数包装在查询参数中payload
。例如,要搜索 id 为“1”或“2”的用户,请从您的后端调用(假设us-east-1
区域):
未编码:
GET https://chat-us-east-1.stream-io-api.com/users?api_key=YOUR_APP_ID&payload={"filter_conditions":{"id":{"$in":["1", "2"]}}}
编码:
https://chat-us-east-1.stream-io-api.com/users?api_key=YOUR_APP_ID&payload=%7B%22filter_conditions%22%3A%7B%22id%22%3A%7B%22%24in%22%3A%5B%221%22%2C%20%222%22%5D%7D%7D%7D
还要确保您在此处根据他们的文档正确设置Stream-Auth-Type
和设置: https ://getstream.io/chat/docs_rest/#authenticationAuthorization
推荐阅读
- javascript - forEach 可以用于在Javascript中增加或减少超过1吗?
- java - 如何在 Maven 项目中正确导入 org.w3c.dom?
- angular - 如何在 Angular 5 中验证表单数组中的电子邮件或电话字段?
- jmeter - 如何从响应数据中获取 href URL 中的特定属性值
- visual-studio-2010 - 删除逗号或将逗号更改为空格 SSIS 2010
- c - 没有定义的静态函数声明
- debugging - VS Code – 通过键盘跳转到当前调试位置
- batch-file - 如何删除批处理文件中新生成的文件
- ios - CKError.Code.networkFailure 什么时候会发生?如何解决?
- c++ - 如何调用结构数组来运行?