# ActiveResource: Howto use custom header fields

**URL:** <https://discuss.rubyonrails.org/t/activeresource-howto-use-custom-header-fields/12394>\
**Category:** rubyonrails-talk\
**Created:** [May 1, 2007, 10:53pm UTC](https://discuss.rubyonrails.org/t/activeresource-howto-use-custom-header-fields/12394 "2007-05-01T22:53:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Mayer](https://avatars.discourse-cdn.com/v4/letter/c/a6a055/32.png) [@Christian\_Mayer](https://discuss.rubyonrails.org/u/Christian_Mayer)\
**Post date:** [May 1, 2007, 10:53pm UTC](https://discuss.rubyonrails.org/t/activeresource-howto-use-custom-header-fields/12394/1 "2007-05-01T22:53:38Z")

</div>

Hi,

I'm using the ActiveResource (beta) gem. I need to change the header fields for the request. There is "default\_header" in ActiveResource::Connection which is "Content-type: application/xml". I do not see how to change that. Could someone give me a hint.

TIA & regards, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chris

---

<div class="post-metadata">

**Author:** ![DHH](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/dhh/32/618_2.png) [@DHH](https://discuss.rubyonrails.org/u/DHH)\
**Post date:** [May 2, 2007, 12:28am UTC](https://discuss.rubyonrails.org/t/activeresource-howto-use-custom-header-fields/12394/2 "2007-05-02T00:28:38Z")

</div>

> There is "default\_header" in ActiveResource::Connection which is "Content-type: application/xml". I do not see how to change that. Could someone give me a hint.

class Project \< ActiveResource::Base &nbsp;&nbsp;headers['X-Token'] = 'foo' end

Adds the X-Token header to all requests.

---

<div class="post-metadata">

**Author:** ![Christian\_Mayer](https://avatars.discourse-cdn.com/v4/letter/c/a6a055/32.png) [@Christian\_Mayer](https://discuss.rubyonrails.org/u/Christian_Mayer)\
**Post date:** [May 2, 2007, 1:17pm UTC](https://discuss.rubyonrails.org/t/activeresource-howto-use-custom-header-fields/12394/3 "2007-05-02T13:17:27Z")

</div>

Hello,

> \> There is "default\_header" in ActiveResource::Connection which is \> "Content-type: application/xml". I do not see how to change that. \> Could someone give me a hint.

> class Project \< ActiveResource::Base &nbsp;&nbsp;headers['X-Token'] = 'foo' end
> 
> Adds the X-Token header to all requests.

Thank you for your help. The "headers" methods isn't yet included in the ActiveResource gem. However, due to your hint, I downloaded at the SVN sources and it works.

regards, &nbsp;&nbsp;&nbsp;chris

---

<div class="post-metadata">

**Author:** ![DHH](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/dhh/32/618_2.png) [@DHH](https://discuss.rubyonrails.org/u/DHH)\
**Post date:** [May 2, 2007, 10:24pm UTC](https://discuss.rubyonrails.org/t/activeresource-howto-use-custom-header-fields/12394/4 "2007-05-02T22:24:24Z")

</div>

> Thank you for your help. The "headers" methods isn't yet included in the ActiveResource gem. However, due to your hint, I downloaded at the SVN sources and it works.

Pushed the latest as beta gems.
