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
8
votes
1 answer

Uploading multiple files in the same request

I need to create a POST where I can upload multiple files in the same request, but I don't know how to write this with grape. Right now to upload just one file this is what I'm doing and It's working fine: desc 'Creates a new attachment.' params do …
Andres
  • 11,439
  • 12
  • 48
  • 87
7
votes
1 answer

Rails 4.2 - Grape - IOError: Not opened for reading

I'm building an API with Grape on Rails 4.2. Here's a link to the repo on GitHub. On the frontend, I have a JavaScript application built with EmberJS. Here's the link to the repo on GitHub as well. I have updated the following gems so that I can…
Lionel Rudaz
  • 173
  • 1
  • 10
7
votes
4 answers

remove quotes from returned string of grape api

I want to return raw data/blob from my grape/rest api. I followed the thread at : https://github.com/intridea/grape/issues/412 for a code like : get 'foo' do content_type 'text/plain' "hello world" end 1) I used : format 'txt' - I got quoted…
resultsway
  • 12,299
  • 7
  • 36
  • 43
7
votes
5 answers

Swagger-ui only sending OPTIONS not POST http method despite working API

I am using Swagger-UI to browse my own API, built with grape and automatically documented with grape-swagger. I've googled and tried every suggestion I can find, but I cannot get POST to work. Here's my headers: header…
Richard Jordan
  • 8,066
  • 3
  • 39
  • 45
6
votes
1 answer

Rails Grape, DRY Helpers call for shared params

Objective: Use grape Shared Params from a helper module, without having to add the syntax helpers Helper::Module on every mounted API. Example code that works: # /app/api/v1/helpers.rb module V1 module Helpers extend Grape::API::Helpers …
Matis Masters
  • 61
  • 1
  • 2
6
votes
2 answers

Set status code in Grape gem

How does one customise the status code response when using the Grape gem? e.g. post do status = :accepted @order = Order.find(params[:id]) end This can be achieved for with error!({ error: 'Order not found'}, 404) but how does one do it for…
TrevTheDev
  • 2,616
  • 2
  • 18
  • 36
6
votes
2 answers

Building XML API with Grape

I'm building a XML API with the help of the Grape gem. What is the best way to building XML for API actions? Since Grape isn't using standart rails controllers, i can't use views/../xml.builder. What did you suggest? Maybe there are some best…
Mikhail Nikalyukin
  • 11,867
  • 1
  • 46
  • 70
5
votes
0 answers

grape - table read as a constant

I'm using rails 5 and grape for api, I'm trying to create grape endpoint for the table application. module PROJ::API::V2 class Applications < ::Grape::API get '/' do authorize! :read, Application status 200 present…
Anbazhagan p
  • 943
  • 1
  • 14
  • 27
5
votes
0 answers

Rails GrapeAPI + Authlogic undefined method `session'

I'm trying to build an API for login using GrapeAPI and Authlogic. My code looks like this: class Api class V1 class UserSessionsController < Grape::API post :login do @user_session = UserSession.new(params[:user_session]) if…
Florin Ionce
  • 855
  • 7
  • 15
5
votes
0 answers

How To Use authenticate_or_request_with_http_token With Grape?

how can I implement authenticate_or_request_with_http_token in grape API. Below is my code : module Articles class ArticleData < Grape::API include ActionController::HttpAuthentication::Token::ControllerMethods # http_basic do…
Mohamad Afiq
  • 275
  • 1
  • 5
  • 14
5
votes
2 answers

Require authorization for Swagger documentation

I'm using grape, grape-swagger, and grape-swagger-rails to set up an API for my Rails 4.2.1 project. It's going to be an internal API, so I want developers to be able to access it, but not the general public. What's the best way to do that? My…
Waynn Lue
  • 11,344
  • 8
  • 51
  • 76
5
votes
1 answer

Inheritance is not working in grape

I am using grape redtful-api. I am Unable to inherit common_params in Grape. I defined common _params in class API1 and called it in API2 throws the error. How can I change the code to make this work? module Example class API1 < Grape::API …
Sam
  • 5,040
  • 12
  • 43
  • 95
5
votes
2 answers

Grape::API – Unable to autoload constant Base, expected /app/api/v1/base.rb to define it (LoadError)

I need some help to get Grape::API up and running with Rails 4. I get a Unable to autoload constant Base even though a puts tells me that the class is loaded. What am I doing wrong? app/api/api.rb class API < Grape::API prefix 'api' format…
martins
  • 9,669
  • 11
  • 57
  • 85
5
votes
1 answer

Grape: Using error! and Grape::Middleware after callback

In Grape if you use the error! method it will throw an error and never call the Grape::Endpoint "after" callback. I'd like the app to call an after hook when error! has been called. I've added this piece of middleware to make this happen. class…
jadent
  • 3,674
  • 5
  • 27
  • 32
4
votes
0 answers

How to config Grape API time zone per request

I want to manage multi time zone, in my Grape API, is there a way to add around filter to set the current user's time zone? like this in Rails around_filter :set_time_zone def set_time_zone old_time_zone = Time.zone Time.zone =…
user1883793
  • 4,011
  • 11
  • 36
  • 65
1
2
3
20 21