---
title: "Passing a parameter from request header to the API controller action method"  
description: "Passing a parameter from request header to the API controller action method"  
author: "Anonymous User"  
published: 2014-11-17  
updated: 2014-11-17  
canonical: https://www.mindstick.com/forum/12624/passing-a-parameter-from-request-header-to-the-api-controller-action-method  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Passing a parameter from request header to the API controller action method

I am using [WEB API](https://www.mindstick.com/articles/324352/how-to-create-web-api-in-dot-net-core-3-1-mvc) 2.0 for [REST Service](https://www.mindstick.com/forum/23169/system-servicemodel-communicationexception-to-consume-wcf-rest-service-from-windows-phone-8) [development](https://www.mindstick.com/articles/65309/importance-of-ux-design-in-the-development-of-mobile-apps) and I need to pass a [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) from request header to the API [controller action](https://www.mindstick.com/forum/34400/how-to-retrieve-form-values-in-controller-action) method. How can I?

By default [API controller](https://www.mindstick.com/forum/159704/what-is-the-use-of-the-producesresponsetype-attribute-in-a-dot-net-core-api-controller-method) is reading the [parameters](https://www.mindstick.com/articles/87/passing-parameters-in-c-sharp) from [request body](https://www.mindstick.com/forum/159965/how-can-you-read-data-from-the-request-body-in-an-express-js-application). How can I make it read parameter from request header?

```
[HttpPost][Route("abc")]public IHttpActionResult abcMethod(string s){   //some code}
```

I want the above abcMethod to read it's parameter from request header.

Pls suggest.

## Replies

### Reply by Sumit Kesarwani

Hi John, try this:

```
IEnumerable<string> headerValues =request.Headers.GetValues("MyCustomID");var id = headerValues.FirstOrDefault();
```


---

Original Source: https://www.mindstick.com/forum/12624/passing-a-parameter-from-request-header-to-the-api-controller-action-method

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
