The code of the Run
method of my Azure Function is this:
public static void Run([HttpTrigger("get")] HttpRequest req, ILogger log) {
string parameter = req.Query["parameter"];
if (string.IsNullOrEmpty(parameter)) {
throw new ArgumentNullException("Parameter must be set.");
}
log.LogInformation(parameter);
}
I have the following cases when running the Function and passing the parameter to the HTTP request:
/api/ServiceBusOutput
): exception (correct)/api/ServiceBusOutput?parameter
): exception (correct)/api/ServiceBusOutput?parameter=""
): success but it should fail (the URL becomes /api/ServiceBusOutput?parameter=%22%22
)/api/ServiceBusOutput?parameter="something"
): success (correct)How can I do to make the third test to fail?
The value ""
is a valid query string parameter. String values would not be passed in quotes via a URL.
For example, if you want to receive the word something
as the parameter, it would be passed as /api/ServiceBusOutput?parameter=something
.
If you are trying to test an empty string value any of the following would work.
/api/ServiceBusOutput?parameter=
/api/ServiceBusOutput