Questions tagged [grape-api]

Grape is a Ruby Gem that provides a DSL to easily develop RESTful APIs.

Grape is a REST-like API micro-framework for Ruby. It’s designed to run on Rack or complement existing web application frameworks such as Rails and Sinatra by providing a simple DSL to easily develop RESTful APIs.

307 questions
2
votes
2 answers

Rails Grape api versioning module structure

I'm trying to implement api versioning, almost the same as I've done here . but i don't seem to get module/folder structure right in rails app, because I get error messages like V1 is not a module /app/api/v1/xml_responses/device.rb:3:in…
Elmor
  • 4,775
  • 6
  • 38
  • 70
2
votes
1 answer

Can open-uri be used across rack applications?

Currently I have a Sinatra web app & a Grape API, the idea being to implement the Sinatra app in such a way that the web app is just another API consumer. In my config.ru I have this: run Rack::Cascade.new [API, Application] API is the Grape app &…
Don Wei
  • 431
  • 5
  • 16
2
votes
1 answer

Using CORS and Warden in rack app (Grape API)

I have a Grape-based API running as a rack application, using rack-cors to allow cross-origin requests, and Warden for authentication. CORS is working as expected, but not in cases where I invoke env['warden'].authenticate. In these cases, I get an…
bwest
  • 9,182
  • 3
  • 28
  • 58
2
votes
3 answers

Ruby Grape: json output is escaped

I am working on a sample Ruby / Grape example, and everything works except the json is served escaped. I am brand new too ruby and its frameworks (just 3 days), so sorry if this question is remedial and thhank you in advance I am fairly certain…
akaphenom
  • 6,728
  • 10
  • 59
  • 109
2
votes
1 answer

Grape API and HTTP Digest Authentication

I am working on creating an API for my ruby application that authenticates users based on HTTP Digest Authentication. I decided to use the Grape API library because it makes creating an API cleaner in ruby. The Grape documentation states that you…
ny95
  • 680
  • 5
  • 17
2
votes
1 answer

Rails 3.2.11 & Grape cannot such file: app/api/v1.rb

I trying to run Grape API in Rails 3.2.11 app. According to grape documentation I should add following lines to my config/application.rb. # Auto-load API and its subdirectories config.paths.add "app/api", :glob => "**/*.rb" config.autoload_paths +=…
Zeck
  • 6,433
  • 21
  • 71
  • 111
2
votes
1 answer

POSTing complex JSON with the grape API into PostgreSQL

I'm trying to create an API using grape, which saves the JSON data to PostgreSQL when posted. Here is the sample JSON: { "about": "this is about me", "company_name": "David Co", "company_url": "http://google.com", "created_at":…
iJade
  • 23,144
  • 56
  • 154
  • 243
2
votes
2 answers

is there a way to modify or send custom headers on grape?

I'm using Goliath and Grape. On my goliath server it calls the grape api like so: when '/posts' then FrameworksAPI::API.call(env) On my grape api class, my method is as simple as this: get '/:id' do Post.find(params[:id]) end I'd like to modify…
David
  • 4,235
  • 12
  • 44
  • 52
2
votes
3 answers

why am i getting an HTTP 405 when doing POST with Ruby Grape

my code is pretty straightforward: class App < Grape::API resource :pincards do post '/' do end end end and i would make a POST /pincards but i end up getting HTTP 405 not allowed. Note that if i changed the "post" to: get '/'…
David
  • 4,235
  • 12
  • 44
  • 52
1
vote
1 answer

Understanding how to authenticate users from Android to Rails app

I have a rails application, and I authenticate users to the application using Devise. The question is that I'm building an Android application and I want to understand how is the flow of authenticating users on the android "the easy way". I read…
amrnt
  • 1,331
  • 13
  • 30
1
vote
0 answers

How to capture invalid parameters using grape in rails

Suppose an endpoint in the api code is defined with the below structure resources :endpoint do desc 'Fetches all content for this endpoint' params do optional :attr1, type: Integer optional :attr2,…
MrKickass
  • 93
  • 1
  • 13
1
vote
0 answers

How to set locale with Grape API / Rails

I have a Rails 6 app and a related API with grape. I want to set locale the same way. In my routes : scope '(:locale)', locale: /#{I18n.available_locales.join("|")}/ do mount MyApi::Api => '/api' resources :users # [....] …
LiKaZ
  • 306
  • 3
  • 9
1
vote
2 answers

added root in grape api but not included in response

I am following this article to learn about writing api using grape gem. But in the response I am not getting the root key. Here is my directory structure, app |––controllers |––api |––base.rb |––v1 …
Gurunath
  • 341
  • 3
  • 17
1
vote
0 answers

How to send the zip file in Rails via Grape API

I have a set of files that are present in s3 and I have to zip them all and send the zipped file to the front end(ReactJS). I am successfully able to create a folder in the tmp of the project and also zip them. Unfortunately, I get the error when I…
1
vote
1 answer

Ruby on Rails Grape API omitting attributes

I'm building a grape API in RoR, and I'm trying to make a GET end-point for my model, but the user_id, created_at and updated_at attributes get cut off from the actual JSON object. This is my end-point: resource :pairings do desc 'Gets all…
Lime Icing
  • 43
  • 6