首页 > 解决方案 > 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 中添加请求有效负载吗?

谢谢!

标签: javajwtgetstream-io

解决方案


正如 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


推荐阅读