Benjamin Benjamin
Benjamin Benjamin

Reputation: 55

Webresponse inside aws Lambda function c#

I'm trying to create a AWS Lambda function with c# inside the function I will do a WeRequest.

using System.Net;
...
public class Function{
public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context){
...
WebRequest request = WebRequest.Create("http://www.url.de");
// Get the response.
HttpWebResponse apianswer = (HttpWebResponse)request.GetResponse();
...
}}

But GetResponse is not available

The AWS template is using .NETCoreApp.Version=v.1.0 is there no GetResponse usable inside this type of function? Or do I have to install another nuget package? How can I do a webrequest inside the function?

Upvotes: 4

Views: 566

Answers (1)

John Hanley
John Hanley

Reputation: 81416

You should use HttpWebRequest instead of WebRequest.

The WebRequest class is an abstract class. The actual behavior of WebRequest instances at run time is determined by the descendant class returned by the WebRequest.Create method. For more information about default values and exceptions, see the documentation for the descendant classes, such as HttpWebRequest and FileWebRequest.

Upvotes: 1

Related Questions