我正在尝试调用我编写的 firebase 云函数。
我已经使用 Postman 测试了该功能来模拟 HTTP 请求。这是我在 Postman 中调用我的函数时的 JSON 结果:
{
"groups": [
{
"isPublic": true,
"members": [
true
],
"numberOfMembers": 1,
"groupId": "-LAOPAzMGzOd9qULPxue"
},
{
"isPublic": true,
"members": [
true
],
"numberOfMembers": 1,
"groupId": "-LAOP7ISDI2JPzAgTYGi"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试执行相同的操作并在我的 android 应用程序中检索此 JSON 列表。我正在关注 Firebase 网站上的示例:https ://firebase.google.com/docs/functions/callable
这是 Firebase 关于如何检索数据的示例:
return mFunctions
.getHttpsCallable("addMessage")
.call(data)
.continueWith(new Continuation<HttpsCallableResult, String>() {
@Override
public String then(@NonNull Task<HttpsCallableResult> task) throws Exception {
String result = (String) task.getResult().getData();
return result;
}
});
Run Code Online (Sandbox Code Playgroud)
目前尚不清楚如何从我的云功能中获取结果并将其用于我的 …
我希望能够在Spring中将某些变量定义为非空@RequestBody。这样,Spring 的控制器将拒绝其主体不具有我定义为关键的某些变量的任何请求。我已经尝试过下面的代码,但它不起作用:
控制器:
@PutMapping("/")
ResponseEntity updateOptions(
@RequestBody RequestDto requestDto
);
Run Code Online (Sandbox Code Playgroud)
RequestDto,我希望第一个参数始终被填充:
import javax.validation.constraints.NotNull;
public class RequestDto {
@NotNull
String id;
String message;
}
Run Code Online (Sandbox Code Playgroud)