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

  • SEARCH
  • Home
  • 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 7488451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:55:00+00:00 2026-05-29T14:55:00+00:00

I’ve been working in the Rails console with Rails 3.2 and I’m generating an

  • 0

I’ve been working in the Rails console with Rails 3.2 and I’m generating an XML file using Nokogiri. From here, I need to post to an external API to grab some data and return it within my app. Eventually this code will be a function of the controller, but for now I’ve been experimenting in the console.

I generated and XML file with Nokogiri and parameters I specified, and I stored the output using the following command:

File.open('results.xml', 'w') {|f| f.write(results)}

From here, I want to POST this file to the external API. The command I used saved it in the /public directory of my app. From here, I’m unsure of how to access it with cURL.

I tried putting it in a views directory and set up a route so I can GET the file, and I can at least access it. Here is what I tried in cURL (note that the Rails server was running at the time and the API path below is made up for example purposes):

curl -X POST -v --data-ascii http://localhost:3000/search/postresults.xml http://APIPATH/example.php

This one has been frustrating me for awhile, and when I try that I get an error saying:

SyntaxError: (irb):5: syntax error, unexpected tCONSTANT, expecting keyword_do or '{'  or '('
curl -X POST -v --data-ascii http://local...
        ^
(irb):5: syntax error, unexpected tUMINUS, expecting keyword_do or '{' or '('
curl -X POST -v --data-ascii http://localhost:...
             ^
(irb):5: syntax error, unexpected tLABEL, expecting keyword_do or '{' or '('
...l 
-X POST -v --data-ascii http://localhost:3000/search/postr...
...                               ^
(irb):5: unknown regexp options - lcalht

I’ve tried all of the standard troubleshooting (curl is installed – version 0.0.9, server is running, curl is in my Gemfile, etc), so any help is much appreciated. Thanks!

  • 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-05-29T14:55:01+00:00Added an answer on May 29, 2026 at 2:55 pm

    Your errors suggest that you typed the curl command and arguments directly into IRb. That’s not how Ruby gems work. Furthermore, if you want to POST to an HTTP resource from Rails don’t bother with cURL. Rails has built-in tools for this.

    If you’re going to be interacting with this API a lot, and if the API is fairly RESTy, then take a look at ActiveResource (tutorials abound on Google if the docs don’t do it for you).

    If you’re not using a very RESTy API, or if this is a one-off API call, you can create an instance of ActiveResource::Connection directly, e.g.:

    conn = ActiveResource::Connection.new 'http://example.com'
    
    result = conn.post 'example.php', results
    

    There’s likely no need to write the Nokogiri document (results) to a file, just give it directly to ActiveResource::Connection#post.

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

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
That's pretty much it. I'm using Nokogiri to scrape a web page what has
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.