Azure / Azure/Azure-Functions

Unable to use the built-in model binding while retaining access to the context with functions v2

Open
#1,147 5 comments 3 reactions 0 assignees View on GitHub
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

I need to create a POST function, so I can send data to it. I want to leverage the ability to send JSON or XML, using the appropriate headers, and the automatic model binding.

I can do this:

```
[FunctionName("CreateAccount")]
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "CreateAccount")] CreateAccountModel createAccountModel,
ILogger log)
```

However I don't get access to the http context, so I can't check the headers for my authorisation token etc.

I would have to change it to `HttpRequestMessage request` to be able to access this, but then I lose the model binding, and have to do a lot of work to get this working myself (write code to see if the data 'looks like' json or xml, deserialize to an object).

I think there should be some way to leverage both of these, such as `HttpRequestMessage request` but I've not been able to find a way.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.