ruby - Post to Sinatra API with hyperresource -


I created an app in Sinatra with cry (hala / json) and now i have to post a new item I am trying to get the customer to this API.

My path to my Sinatra app is: Extend (todo.representer) @ todo.to_json erb: 'todos / new' end post "/ todos" Do @todo = todo.new (params [todo]) if @todo.save redirects "todos / # {@ todo." Id} "and arb:" todos / new "end end

and my client.rb looks like this:

  is required 'hyperSource 'Class APIRQUEST & Lt; Hyper Resource API = APIIEET.N. (Route: 'http://127.0.0.1:9393', Header: {'Acceptance' => 'Application / vnd.http: //127.0.0.1: 9393.v1 + json '}) Api.post' / todos / new ', {: title = & gt; "A"}  

This does not work The only way to get a working client is to get function:

  Requires 'hyperites' class APIIQUEST & lt; Hyper Resource API = APIIEET.net (Route: 'http://127.0.0.1:9393/todos/13', Header: {'Acceptance' => 'Application / vnd.http: //127.0.0.1: 9393 .v1 + Json '}} todo = api.get output = todo.body puts output  

I do not know how this is sorted out, and the zithub page does not tell me.


I changed the little API:

  get '/ todos' do @pagetitle =' new todo '@todo = todo.new erb:' todos / new 'And Post' / Tudos / New 'Dot @ Todo = Todo.New (Param [[Tudo]) @ Tudo. Adend (Todo Rezzer) @ Tudo.To_ Sun @ @ todo.save Redirect "todos / # {@ todo.id}" and Ab: "todos / new" end and  

and how to post in my clients: < / P>

  todo = api.get.new_todo post (title: "test")  

I now find it in my API console:

< "Tudos" from "Tudos". "Id" =? Limit: D, [2014-11-04T17: 11: 41.875218 # 11111] DEBUG -: Todo Load (0.1 ms) SELECT "TODOS". 1 [["ID", 0]] ActiveWorld :: Record Notaffand - 'Eddy' = New:

And Todd could not find with many other codes.

In my client console I get a lot of code with a lot processing server error and many other code.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -