पर पोस्ट करना मेरे पास एक साधारण सी # Aws Lambda फ़ंक्शन है जो लैम्ब्डा कंसोल टेस्ट से परीक्षण में सफल होता है लेकिन एपीआई गेटवे (जिसे मैंने उत्पन्न किया है) से 502 (खराब गेटवे) के साथ विफल रहता है ।एडब्ल्यूएस-एपीआई गेटवे से लैम्ब्डा
Wed Feb 08 14:14:54 UTC 2017 : Endpoint response body before transformations: {
"errorType": "NullReferenceException",
"errorMessage": "Object reference not set to an instance of an object.",
"stackTrace": [
"at blahblahmynamespace.Function.FunctionHandler(ZipRequest input, ILambdaContext context)",
"at lambda_method(Closure , Stream , Stream , ContextInfo)"
]
}
यह की तरह लगता है: लैम्ब्डा ट्रिगर विकल्प) है और यह भी अगर मैं डाकिया का उपयोग)
// request header
Content-Type: application/json
// request body
{
"userid":22,
"files":["File1","File2","File3","File4"]
}
त्रुटि मैं लॉग में मिलता है (इस प्रारंभिक समारोह ओपन एक्सेस (कोई सुरक्षा है) पोस्ट ऑब्जेक्ट लैम्ब्डा इनपुट तर्क में पारित नहीं किया जा रहा है।
कोड
नीचे// Lambda function
public LambdaResponse FunctionHandler(ZipRequest input, ILambdaContext context)
{
try
{
var logger = context.Logger;
var headers = new Dictionary<string, string>();
if (input == null || input.files.Count == 0)
{
logger.LogLine($"input was null");
headers.Add("testheader", "ohdear");
return new LambdaResponse { body = "fail", headers = headers, statusCode = HttpStatusCode.BadRequest };
}
else
{
logger.LogLine($"recieved request from user{input?.userid}");
logger.LogLine($"recieved {input?.files?.Count} items to zip");
headers.Add("testheader", "yeah");
return new LambdaResponse { body = "hurrah", headers = headers, statusCode = HttpStatusCode.OK };
}
}
catch (Exception ex)
{
throw ex;
}
}
// लैम्ब्डा प्रतिक्रिया/ZipRequest वर्ग
public class LambdaResponse
{
public HttpStatusCode statusCode { get; set; }
public Dictionary<string, string> headers { get; set; }
public string body { get; set; }
}
public class ZipRequest
{
public int userid { get; set; }
public IList<string> files { get; set; }
}