【发布时间】:2015-12-24 23:11:17
【问题描述】:
我将 python 用于我的服务器 Google App Engine API 代码和我的客户端。我已经有很多客户端-服务器 GET 请求在工作,现在是 POST 请求的时候了,我被困住了。我的相关客户代码:
service = build("myAPI", "v1", http=http, discoveryServiceUrl=DISCOVERY_URL)
service.updateUser(websafeKey=websafeKey).execute()
我不知道如何构建 POST 请求的正文。在那之后,我将被困在试图弄清楚如何告诉 service 以便它可以将请求发送到我的 updateUser API。
POST 请求正文需要包含一些字符串和几个列表,之后可能还需要一个 python Date 对象。
我的updateUser API 在 API Explorer 中运行良好 - 我可以整天成功地updateUser:
USER_POST_REQUEST = endpoints.ResourceContainer(
UserForm, websafeKey=messages.StringField(1),)
@endpoints.method(USER_POST_REQUEST, UserForm,
path='useradmin/{websafeKey}',
http_method='PUT', name='updateUser')
def updateUser(self, request):
"""Update user w/provided fields & return w/updated info."""
return self._updateUserObject(request)
【问题讨论】:
标签: python google-app-engine http-post google-api-client