Making calls from the Javascript client library with @Named and unnamed parameters makes no sense

二次信任 提交于 2019-12-04 17:56:48

Is the API method correctly recognized as POST method?

The resource parameter which is sent as POST body won't work correctly in a GET request. The way it looks you are actually sending a GET request with the Hylyt properties in the query string.

To make sure you can change the method annotation to this:

@ApiMethod(name = "hylyts.insert", httpMethod = HttpMethod.POST)
da Bich

Yup, agreed it's a bug. caused me great pains as well.

So i guess the work around is to create a combined object to pass to your api all named and un named parameters. Rather than hardcode each.. a quick loop might be better.

var param = {};
param["url"] = url;
for (var prop in hylyt) {
  param[prop] = hylyt[prop];
}
gapi.client.hylytit.hylyts.insert(param).execute(callback);

That mashing together of parameters / objects can become a slick function if you really want.. but it's a band aid for what I'd consider a defect. I see in the related question (cloud endpoints resource attribute for transmitting named params & body not working), you actually logged a defect.. Good stuff. Though there still appears no movement on this one. fingers crossed for someday!

The bug has been resolved. The correct syntax is

gapi.client.hylytit.hylyts.insert({url: url}, hylyt).execute(callback);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!