调用服务#
功能介绍#
同步调用函数服务。
URI#
POST /serverless/v1/functions/{functionVersionURN}/invocations
路径参数:
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
functionVersionURN |
是 |
String |
函数版本 URN。 |
请求参数#
请求 Header 参数
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
Content-Type |
是 |
string |
消息体类型。 |
Accept |
否 |
string |
是否使用 SSE 流式返回。 |
X-Instance-Cpu |
否 |
string |
函数实例所需 CPU。 |
X-Instance-Memory |
否 |
string |
函数实例所需 Memory。 |
X-Instance-Custom-Resource |
否 |
string |
函数实例所需自定义资源。 |
X-Pool-Label |
否 |
string |
函数实例所需亲和的资源池标签。 |
X-Instance-Label |
否 |
string |
在具有该标签的函数实例上运行。 |
X-Instance-Session |
否 |
string |
指定实例会话调用,会话与实例唯一绑定。 |
X-Session-Context |
否 |
string |
指定 Session Context。仅当函数元数据 |
请求 Body 参数
用户函数自定义格式。
响应参数#
用户函数自定义格式。
请求示例#
POST {frontend endpoint}/serverless/v1/functions/{functionVersionURN}/invocations
{
"name":"yuanrong"
}
启用 enableSessionCtx 的函数可在调用时通过 X-Session-Context 指定 Session Context:
curl -X POST "{frontend endpoint}/serverless/v1/functions/{functionVersionURN}/invocations" \
-H "Content-Type: application/json" \
-H 'X-Session-Context: {"sessionCtx":"ctx-a"}' \
-d '{"name":"yuanrong"}'
响应示例#
状态码:200
表示调用函数成功。
"hello yuanrong"
错误码#
请参见错误码