问题描述
我试图通过gapi.client rpc调用实现对谷歌云端点的调用。如文档(和),应该可以包含命名参数和对象主体:
<$ p
public Staff insertStaff(@Named(token)String token,Staff staff)抛出ConflictException异常, NotFoundException,InternalServerErrorException {
应该可以通过
调用 var staff = {};
staff.id = environment.getStaffId();
staff.name =Johnny;
staff.createdAt = new Date();
staff.modifiedAt = new Date();
var par = {'token':mytoken,'resource':staff};
api.staff.insert(par).execute(function(res){
});
我无法得到这个工作,我总是在java端点中获得一个空的staff对象,但是正确的标记。这是在dev env(1.8.8)和appengine上。 gapi.client版本是1.1.0-beta。
端点工作良好,当通过api资源管理器(使用rest来代替rpc)和android生成的端点库(也使用json rest)。
在chrome调试器中转储rpc请求表明有一个params字典,其中包含资源字典和令牌参数它看起来不像资源属性由gapi.client专门处理。这是怎么回事,端点代码有资源参数的特殊处理程序?或者这是一个gapi问题?
在gapi.client混淆源代码中使用chrome调试器,并在唯一字符串resource发生处设置断点时,断点不会被击中。我在格式化params / body时做了什么错误?有任何想法吗?或者我可以澄清有关我的设置的问题?
(我也在gapi.client讨论组上发布了这个问题,但不清楚问题是在gapi还是in终点)
它没有任何意义,但试试这个:
var date = new Date();
var par = {$ b $'token':'mytoken',
'id':environment.getStaffId(),
'name':Johnny,
'createdAt':日期,
'modifiedAt':日期
}
我'抱怨这个在过去。
I am trying to implement a call to a google cloud endpoint via the gapi.client rpc calls. As described in the docs (and Google Cloud Endpoints - Making calls with JS client, passing params and JSON body), it should be possible to include named parameters and an object body:
@ApiMethod(name = "staff.insert", httpMethod="post")
public Staff insertStaff(@Named("token") String token, Staff staff) throws ConflictException, NotFoundException, InternalServerErrorException {
should be callable via
var staff = {};
staff.id = environment.getStaffId();
staff.name = "Johnny";
staff.createdAt = new Date();
staff.modifiedAt = new Date();
var par = { 'token' : "mytoken", 'resource' : staff};
api.staff.insert(par).execute(function(res) {
});
I cannot get this to work, I always get an empty staff object in the java endpoint, but a correct token. This is on dev env (1.8.8) and on appengine. gapi.client version is 1.1.0-beta.
The endpoint works fine with correct staff being transmitted when used via api explorer (which uses rest instead of rpc) and android generated endpoint libraries (also using json rest).
Dumping the rpc request in the chrome debugger shows that there is a params dictionary that has the resource dictionary and the token params inside, it does not look like the resource attribute is handled specially by gapi.client. Is this how it should be, and the endpoints code has special handlers for "resource" params? or is this a gapi problem?
Using the chrome debugger on the gapi.client obfuscated source and setting a breakpoint on the only string occurance of "resource" I could find, the breakpoint is never hit. Am I doing something wrong with formatting the params / body? Any ideas? Or questions I could clarify about my setup?
(I also posted the question on the gapi.client discussion group, but its not clear if the problem is in gapi or in endpoints)
It makes no sense, but try this:
var date = new Date();
var par = {
'token': 'mytoken',
'id': environment.getStaffId(),
'name': "Johnny",
'createdAt': date,
'modifiedAt': date
}
I've complained about this in the past.
这篇关于云端点资源属性用于传输命名参数&身体不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!