云端点。
我正在遵循Udacity教程。我对请求和响应的流程有点困惑,以下是我的理解
端点应使用@Api注解,端点方法应使用@ApiMethod注解,并且这些方法不应返回原始数据types.the下面是一个端点方法
@ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST)
public Profile saveProfile(ProfileForm profileForm) throws UnauthorizedException {
String userId = null;
String mainEmail = null;
String displayName = "Your name will go here";
TeeShirtSize teeShirtSize = TeeShirtSize.NOT_SPECIFIED;
if(profileForm.getTeeShirtSize() != null)
teeShirtSize = profileForm.getTeeShirtSize();
displayName = profileForm.getDisplayName();
Profile profile = new Profile(userId, displayName, mainEmail, teeShirtSize);
return profile;
}下面是我的ProfileForm和配置文件类
public class ProfileForm {
private String displayName;
private TeeShirtSize teeShirtSize;
private ProfileForm () {}
public ProfileForm(String displayName, TeeShirtSize teeShirtSize) {
this.displayName = displayName;
this.teeShirtSize = teeShirtSize;
}
public String getDisplayName() {
return displayName;
}
public TeeShirtSize getTeeShirtSize() {
return teeShirtSize;
}
public static enum TeeShirtSize {
NOT_SPECIFIED,
XS,
S,
M,
L,
XL,
XXL,
XXXL
}
}public class Profile {
String displayName;
String mainEmail;
TeeShirtSize teeShirtSize;
String userId;
public Profile (String userId, String displayName, String mainEmail, TeeShirtSize teeShirtSize) {
this.userId = userId;
this.displayName = displayName;
this.mainEmail = mainEmail;
this.teeShirtSize = teeShirtSize;
}
public String getDisplayName() {
return displayName;
}
public String getMainEmail() {
return mainEmail;
}
public TeeShirtSize getTeeShirtSize() {
return teeShirtSize;
}
public String getUserId() {
return userId;
}
private Profile() {}
}这里,ProfileForm是请求参数,Profile是响应参数。i部署在本地主机中,并使用我测试过的以下url
http://localhost:8080/_ah/api/explorer在请求体中我添加了两个参数作为displayName,teeShirtSize,所以谁能解释一下为什么我得到的响应是404?下面是屏幕截图

据我所知,我不需要加载appengine client.js,因为我没有在网页上测试。我正在api- explain中测试,请解释一下当您调用google-cloud-endpoint时如何生成响应?
谢谢
发布于 2015-05-04 11:07:12
我使用了1.9.3版本的google-app-engine,然后我改成了1.9.20,现在它工作得很好。尽管如此,我还是提出了很多问题,比如为什么它在1.9.3中不能工作?
谢谢
发布于 2015-05-05 00:27:00
很可能(但不确定,因为我看不到您的根注释)它不工作是因为您在注释中设置了@Api参数。最近的一些变化使得API浏览器始终尊重根目录,这打破了本地的开发经验。最近的SDK版本对此进行了更改,以使其再次工作。如果你注意到了,你的浏览器截图是这样写的:
配置文件POST _ah/api/
/v1/profile
应该是这样写的:
POST _ah/api/conference/v1/profile
https://stackoverflow.com/questions/29999341
复制相似问题