j9九游会登录/ 函数工作流 functiongraph/ 常见问题/ 调用函数/ 使用apig触发器调用一个返回string的functiongraph函数时,报500错误
更新时间:2025-01-07 gmt 08:00

使用apig触发器调用一个返回string的functiongraph函数时,报500错误-j9九游会登录

functiongraph函数对来自apig调用的返回结果进行了封装,apig触发器要求函数的返回结果中必须包含body(string)、statuscode(int)、headers(map)和isbase64encoded(boolean),才可以正确返回。

node.js函数apig触发器调用返回结果定义示例如下:

exports.handler = function (event, context, callback) {
    const response = {
        'statuscode': 200,
        'isbase64encoded': false,
        'headers': {
            "content-type": "application/json"
        },
        'body': 'hello, functiongraph with apig',
    }
    callback(null, response);
}

java函数apig触发器调用返回结果定义示例如下:

import java.util.map;
public httptriggerresponse index(string event, context context){
        string body = "functionstage"
                  "
" "

this is a simple apig trigger test


" "

this is a simple apig trigger test

" ""; int code = 200; boolean isbase64 = false; map headers = new hashmap(); headers.put("content-type", "text/html; charset=utf-8"); return new httptriggerresponse(body, headers, code, isbase64); } class httptriggerresponse { private string body; private map headers; private int statuscode; private boolean isbase64encoded; public httptriggerresponse(string body, map headers, int statuscode, boolean isbase64encoded){ this.body = body; this.headers = headers; this.statuscode = statuscode; this.isbase64encoded = isbase64encoded; } }

相关文档

网站地图