使用CloudWatch Cron规则时如何提供AWS Lambda JSON?

时间:2017-04-27 18:14:56

标签: c# amazon-web-services lambda amazon-cloudwatch

我在C#中有一个Lambda函数。当我在Lambda的行动 - >测试数据我有这个json(简化,为了人性化):

    {
        "address": "http://website.com",
        "ID": "18",
        "pricingType": "INTERSTATE",
        "reportID": "1443",
        "XML": "<BASICSXMLSTUFF>"
    }

当我点击&#34;测试&#34;时,哪个有效。但是,当我使用CloudWatch Cron规则时,我无法弄清楚如何将此数据发送到该函数。我试图把它放在&#34; Constant(JSON文本)&#34; CloudWatch中的字段,但似乎没有保存,当函数运行时,我得到这个堆栈跟踪:

Unexpected character encountered while parsing value: [. Path 'resources', line 1, position 202.: JsonReaderException
at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
at Newtonsoft.Json.JsonTextReader.ReadAsString()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
at lambda_method(Closure , Stream , Stream , ContextInfo )

如何使用CloudWatch规则将json传递给我的lambda函数?或者我只是完全错了?

1 个答案:

答案 0 :(得分:0)

我想出了我自己的问题,看起来我正在做所有事情,但“常量(JSON文本)”必须有一个字符限制。我传入函数的XML非常大,所以我将其更改为从URL下载而不是以这种方式提供XML,现在一切都运行良好。