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
1
vote
1 answer

Track the total amount of API requests in Grape

I have a set of grape APIs which run on Rack. Is there any way to get total amount of API requests after the server start? Is there any other way how API request count can be tracked?
Hridya
  • 236
  • 2
  • 12
1
vote
1 answer

How do I map the JSON body of a GET request to a parameter?

I have the following definition in my endpoint: params do requires :entities do requires :id, type: String optional :email, type: String optional :phone, type: String end end post "test" do end Note this only works…
blue18hutthutt
  • 3,191
  • 5
  • 34
  • 57
1
vote
1 answer

ruby-grape - requires method not working 3 levels deep

I am building an API right now using Grape and Rails. One endpoint takes POST requests for Orders. The architecture is as follows: An Order has_many OrderDetails. OrderDetails has_many OrderDetailCustomFields. As such, I would expect that POST…
James
  • 624
  • 4
  • 13
1
vote
1 answer

Grape: ActiveModel::ForbiddenAttributesError

When calling my API Endpoint, I am getting this error: ActiveModel::ForbiddenAttributesError (ActiveModel::ForbiddenAttributesError): day_points_api.rb module V1 class DayPointsApi < Grape::API namespace 'api/v1' do resource :points…
davegson
  • 8,205
  • 4
  • 51
  • 71
1
vote
0 answers

Reusable Custom DSL Extension in Grape

I have a custom Grape DSL method called scope that remembers the parameter then delegates some work to the params helper. class API::V1::Walruses < Grape::API resources :walruses do scope :with_tusks, type: Integer, desc: "Return walruses…
Chris
  • 11,819
  • 19
  • 91
  • 145
1
vote
1 answer

Devise user authentication in grape

I have a rails application that contains all front-end part , administrative and register/login/logout (Devise). I also have a part with more dynamic maps that is written in javascript React. It runs on a controller / view separately in the same…
Ricardo
  • 159
  • 1
  • 2
  • 9
1
vote
1 answer

ruby Grape Validation doesn't work

I write requires,like this params do requires :user_id, :type => Integer optional :page, :type => Integer, :default => 1 optional :per_page, :type => Integer, :default => 20 end and I have wrote rescue_from rescue_from :all do |e| …
fcce
  • 1,034
  • 1
  • 12
  • 24
1
vote
0 answers

Is it good approach to use Devise features via Grape?

Devise helps us to login/register users to our Rails applications. It helps us to Confirm emails, recover accounts. It is easy to implement sessions between app and user. It is easy to use Devise when user accesses to your app via Browser. However,…
Mr.D
  • 7,353
  • 13
  • 60
  • 119
1
vote
1 answer

Grape POST request receiving JSON

I am having problem with grape. I have tried to look into their docs and google around. I could not find any solution or sample regarding this. Let say I am sending this kind of format to the POST request of grape: { "preferences": { …
kilua
  • 711
  • 1
  • 9
  • 16
1
vote
1 answer

How can find domain name in Grape::API

I am not able to fetch request object in Grape::API, My method is module Artical module Railsapp module V1 class Articleapi < Grape::API include Railsapp::V1::Defaults resource :articleapi do desc "Return all article" get "",…
1
vote
1 answer

customize Grape API response

I am using Grape GEM in my rails app, How can I customize response if record not found or request params are in valid @video = Video.where(id: permitted_params[:id]).first! for example there is no record for any id
Vipin
  • 111
  • 1
  • 10
1
vote
2 answers

Serving an image with Grape

I have a GET service who should serve an image. Following the Grape readme: https://github.com/intridea/grape#user-content-sending-raw-or-no-data get :image do content_type 'application/octet-stream' File.binread "image.png" end But when I…
Fran b
  • 3,016
  • 6
  • 38
  • 65
1
vote
1 answer

grape-entity represent not working

I am using grape gem for API and grape-entity to generate responses. Simple show/get request is responding fine like returning only data from ActiveRecord Object. Fine When i try to include data from has_many relation it return all the data related…
Abdul Baig
  • 3,683
  • 3
  • 21
  • 48
1
vote
1 answer

Undefined method Class `all' in Rails 4 app

I have been following various Ruby on rails REST API tutorials, specifically those using the GRAPE gem. On all these attempts, I have been encountering a undefined method `all' error. I am new to RoR and have been relying on the generators for model…
TheNoobie
  • 13
  • 2
1
vote
1 answer

How to achieve strong parameter protection without Rails?

I am developing a boilerplate web application with Goliath + Grape + Active Record 4.2 + Active Record Migrations. Here is my migration file # db/migrate/20150519063210_create_albums.rb class CreateAlbums < ActiveRecord::Migration def change …
Aetherus
  • 8,720
  • 1
  • 22
  • 36