Posting in Ruby leads to a 403 error I am writing a Ruby script to ingest content into Drupal 7. This is on my local machine. I'm using the Services module and its rest service to GET and POST. I could log in and grab the csrf token and the cookie information but I get a 403 error when I try to post a new node. I checked my local apache access and error logs. There were no errors listed and the access log only reports the status. This is my code so far:

require "rest-client"
require "json"

node = create_node(node_hsh)
node_json = JSON.generate(node)
response = RestClient.post('localhost/drupal/restfulapi/node', node_json, 
:content_type =&gt; :json, 
:accept =&gt; :json, 
:headers =&gt; {:cookie =&gt; cookie, 'x-csrf-token' =&gt; csrf_token} 
)


I'm not sure where else to look? I would really appreciate any pointers. Thanks.
I figured it out. Posting this for documentation: I had to pass the cookie after the user had logged in to do a GET on the token (localhost/services/session/token) for the Services module. Once I had the token, I could pass the cookie and the token to do a POST of the resources. I also switched the gem from rest-client to Faraday because I could customize my headers better. Also, the logging functionality was more verbose in Faraday which was helpful in debugging.