grape

Ember.js POST requests return 400 from the server (Grape API) but are stored successfully into local storage

假如想象 提交于 2019-12-13 14:30:55
问题 I've been trying to get a simple Ember.js application to post to a Grape API backend for hours now, but I cannot seem to get it to work. I know the API works because I can post new records to it through the Swagger documentation, and they are persisted. I know the API and Ember are talking just fine because I can get all records from the server and interact with them on the page, and I know that Ember is working fine in a vacuum because my records are persisted to local storage. However, I

Groovy Grape is not downloading new revisions

你离开我真会死。 提交于 2019-12-12 15:47:12
问题 I believe I have everything configured correctly such that grape ought to be asking the repository if there is a new revision, but it isn't. As long as the jar exists in .groovy/grapes it uses it. I'm doing the grab via Java code via our application's API, so there can be some pre-processing not as easily handled if the script has @Grab, if that matters.... Map<String,Object> args = new HashMap<String, Object>(); args.put("validate", true); args.put("classLoader", gcl); Map<String,Object>

RestSharp Accept header change

感情迁移 提交于 2019-12-12 08:47:18
问题 I am using RestSharp for developing on the client side. I am also using Ruby Grape gem for my custom API on server side. Grape gem can do versioning by setting Accept HTTP header f.e to application/vnd.twitter-v1+json And test command via console works perfect curl -H Accept=application/vnd.twitter-v1+json /statuses/public_timeline But when I am trying to set up header for RestRequest I am getting error 404 on the server. I have no idea why so. I have found another issue that server returns

PUT method return 405 in RSpec test for API

混江龙づ霸主 提交于 2019-12-12 02:29:44
问题 I am building RESTful web server using Goliath-Grape and using RSpec for TDD. When make the API PUT call (/api/v1/users/:id) to update an existing record from the browser I get the expected 204 response. But when I test the same API call through RSpec I get back 405. And the response header looks like this: PUT /api/v1/users/:id {"ALLOW"=>"OPTIONS, POST, GET, HEAD", "CONTENT_TYPE"=>"text/plain", "CONTENT_LENGTH"=>"0", "SERVER"=>"Goliath", "DATE"=>"Fri, 09 Aug 2013 01:37:09 GMT"} Code snippet

Why won't Groovy/Grape resolve artifacts from Maven Central?

笑着哭i 提交于 2019-12-10 17:56:17
问题 With a fresh download of Groovy 2.1.9, I create: // Test.Groovy @Grab('commons-io:commons-io:1.2') import org.apache.commons.io.CopyUtils println "Resolved!" Then I try running $ ./groovy-2.1.9/bin/groovy Test.groovy which fails with General error during conversion: Error grabbing Grapes -- [download failed: commons-io#commons-io;1.2!commons-io.jar] The artifact is listed in maven central, downloadable here For what it's worth, various local files are created in: ~/.groovy/grapes/commons-io

Activerecord associations as JSON with Grape

非 Y 不嫁゛ 提交于 2019-12-10 07:27:24
问题 Is there a simple way to return activerecord models with associations as JSON using the Grape microframework? get 'users' do User.includes(:address) end This snippet isn't working and User.includes(:address).to_json(include: :address) will get encoded twice as JSON. (To use the to_json method on my own doesn't feel right anyway) 回答1: You might want to use #as_json instead. So you can do User.includes(:address).as_json(include: :address) and that gives you a hash instead of a json string. 回答2:

Grape error handling strategy?

非 Y 不嫁゛ 提交于 2019-12-10 03:36:44
问题 I am using Grape and Rails to create a REST API. I have the basic architecture in place and I am looking for places to 'clean' things up. One of those places is the error handling/processing. I am currently rescuing errors in the root.rb (GRAPE::API base class) file for the whole API. I format them and then send the error back via rack_response. Everything works find but the root.rb file is getting a bit bloated with all the errors being rescued and some of them have special parsing that

Groovy grapes freeze after downloading artifacts

落花浮王杯 提交于 2019-12-07 16:19:43
问题 After updating my ubuntu system I have problem to run groovy grapes scripts. All dependecies are download but process is still running in about 100 % I have ubuntu : lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 12.10 Release: 12.10 Codename: quantal groovy version: Groovy Version: 1.8.6 JVM: 1.7.0_25 Vendor: Oracle Corporation OS: Linux My simple script look like: @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version=

testing rails grape API with curl, params array

折月煮酒 提交于 2019-12-07 14:31:30
问题 I am manually testing my rails application grape API using curl. I would like to send a [1,2,3] array as a request query parameter for to to be accesible like: p params[:tickets_ids] => [1,2,3] I only found clues how to send something what is interpreted as hash . I will be grateful for a clue how to post an array using curl. 回答1: Thank you for the clue. The answer is to encode query like this: ?&tickets_ids[]=1&tickets_ids[]=2&tickets_ids[]=3 Results in: p params[:tickets_ids] => ["1", "2",

Error grabbing Grapes … unresolved dependency … not found

我的梦境 提交于 2019-12-06 04:04:40
问题 UPDATE 8/6: The beefed up logging has shown me that there is an issue deleting the old jar from the cache, which leads to the fatal "not found" error. There are other threads similar to this, but only when someone is locking the file with their IDE. We are running a single groovy script from Jenkins, and no one is logged into this box. We ran process explorer right after the failure and there were no locks. Then I login with the user that Jenkins is using to run the script, and I get no error