Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9062923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:51:30+00:00 2026-06-16T15:51:30+00:00

I am using AngularJS with Rails. I have the following request which updates users

  • 0

I am using AngularJS with Rails. I have the following request which updates users in bulk.

 $http{
    method: 'POST',
    url: $scope.update_url,
    params: {selected_ids: userIds}
 }

This cannot be a ‘GET’ request due to restrictions in the length of the URL (http://support.microsoft.com/kb/208427)

But for ‘POST’ request, we need to have a CSRF authenticity token in the header.

How can we set the CSRF Token to the post request header?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:51:32+00:00Added an answer on June 16, 2026 at 3:51 pm

    You can set http headers as explained in the $http service.

    You can set it up globally:

    $httpProvider.defaults.headers.post['My-Header']='value'   (or)
    $http.defaults.headers.post['My-Header']='value';
    

    or for a single request:

    $http({
       headers: {
          'My-Header': 'value'
       }  
    });
    

    Here is an important quote from Angular:

    Cross Site Request Forgery (XSRF) Protection XSRF is a technique by
    which an unauthorized site can gain your user’s private data. Angular
    provides following mechanism to counter XSRF. When performing XHR
    requests, the $http service reads a token from a cookie called
    XSRF-TOKEN and sets it as the HTTP header X-XSRF-TOKEN. Since only
    JavaScript that runs on your domain could read the cookie, your server
    can be assured that the XHR came from JavaScript running on your
    domain.

    To take advantage of this, your server needs to set a token in a
    JavaScript readable session cookie called XSRF-TOKEN on first HTTP GET
    request. On subsequent non-GET requests the server can verify that the
    cookie matches X-XSRF-TOKEN HTTP header, and therefore be sure that
    only JavaScript running on your domain could have read the token. The
    token must be unique for each user and must be verifiable by the
    server (to prevent the JavaScript making up its own tokens). We
    recommend that the token is a digest of your site’s authentication
    cookie with salt for added security.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using AngularJS with Rails and creating dynamic nested form items which are not
I have a Rails 3.2.8 app in which I'm applying some AngularJS for calculations
I am using AngularJS' http() method to load in a JSON file located on
Using the AngularJS framework, how do I have the Submit button both update the
I have the following Rails HAML: = select_tag some-class, options_for_select([['None', '']], ''), { class:
I'm using AngularJS with my pages, and I have a doubt: when I do
I am using AngularJs for a new application. I feel I have solved a
I am using Angularjs for a web application. I have tried searching to find
I am working on a web app using AngularJS with which I am quite
I'm using AngularJS and I have a little question here. I just made my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.