Webresponse inside aws C # lambda function

I am trying to create an AWS Lambda function using C # inside a function that I will make using 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 uses .NETCoreApp.Version = v.1.0. Isn't there a GetResponse method that can be used inside this type of function? Or do I need to install another nuget package? How can I make a web request inside a function?

+3


source to share


1 answer


You have to use HttpWebRequest instead of WebRequest.



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

0


source







All Articles