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 7678211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:35:34+00:00 2026-05-31T17:35:34+00:00

I am trying to post coordinates for origin and destination to bing api for

  • 0

I am trying to post coordinates for origin and destination to bing api for getting directions. But I am unable to send the data.

 def get_info_from_bing(params)
    base_url="http://dev.virtualearth.net/REST/v1/Routes/"
    query_params = "?" + {
            "wayPoint.1" => params[:origin],
            "waypoint.2" => params[:destination],
            "dateTime" => params[:time] || Time.now.strftime("%H:%M"),
            "timeType" => "Arrival",
            "key" => ENV['BING_KEY']
    }.map {|k,v| "#{k}=#{CGI.escape(v)}"}*"&"
    modes=%w{driving walking transit}

Error:

NoMethodError - undefined method `gsub' for nil:NilClass:
/Users/anirvan/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/cgi/util.rb:7:in `escape'
/Users/anirvan/codeforamerica-transpochoices-1ccac48/choices.rb:15:in `block in get_info_from_bing'
/Users/anirvan/codeforamerica-transpochoices-1ccac48/choices.rb:15:in `each'
/Users/anirvan/codeforamerica-transpochoices-1ccac48/choices.rb:15:in `map'
/Users/anirvan/codeforamerica-transpochoices-1ccac48/choices.rb:15:in `get_info_from_bing'
/Users/anirvan/codeforamerica-transpochoices-1ccac48/choices.rb:120:in `block in <top (required)>'
/Users/anirvan/.rvm/gems/ruby-1.9.2-p318/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212:in `call'
/Users/anirvan/.rvm/gems/ruby-1.9.2-p318/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212:in `block in compile!'
/Users/anirvan/.rvm/gems/ruby-1.9.2-p318/gems/sinatra-1.3.1/lib/sinatra/base.rb:772:in `[]'
/Users/anirvan/.rvm/gems/ruby-1.9.2-p318/gems/sinatra-1.3.1/lib/sinatra/base.rb:772:in `block (3 levels) in route!'

I am new to sinatra and ruby. Does anyone know what the problem is?

  • 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-31T17:35:36+00:00Added an answer on May 31, 2026 at 5:35 pm

    Use params.inspect to print the content of your param array. One of the values is certainly nil, that why CGI.escape(v) throws an exception.

    If you can fix the nil value, use the following line as a workaround:

    ...
    }.map {|k,v| "#{k}=#{CGI.escape(v||'')}"}*"&"
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to POST a http request using ajax, but getting a response from
I am trying to post data to MVC controller action but have been unsuccessful
I am trying to post a cross-domain HTTP request but keep getting a SecurityException
I'm trying POST a check-in request in Google Places API. The way they described
im trying to POST (cross domain) some data to a jersey web service and
Im trying to post a form data in js : I have this code
I am trying to POST data back to the server and get a dataset
I'm trying to post some code snippets on my WordPress blog, but when I
I'm trying to POST some data as if I was using FORM on HTML
I'm trying to post to a facebook wall, without using an API such as

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.