Closed dazza-codes closed 9 years ago
When the OA as jsonld is pasted into the form at /annotations/new, it works OK. But when RestClient does a POST, it fails. The RestClient POST looks like:
[13] pry(main)> tc = Annotations2triannon::TriannonClient.new
=> #<Annotations2triannon::TriannonClient:0x007fa19ca3a788
@config={"host"=>"http://localhost:3000", "user"=>"", "pass"=>""},
@site=#<RestClient::Resource:0x007fa19ca3a5a8 @block=nil, @options={:user=>"", :password=>""}, @url="http://localhost:3000">>
[14] pry(main)> tc.site["/annotations/"].post oa.to_jsonld_oa, :content_type => :json
RestClient::InternalServerError: 500 Internal Server Error
from /home/dlweber/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rest-client-1.7.3/lib/restclient/abstract_response.rb:48:in `return!'
The generic RestClient POST looks like (where oa.to_jsonld_oa data is as above):
RestClient.post "http://localhost:3000/annotations/", oa.to_jsonld_oa, :content_type => :json, :accept => :json
RestClient::InternalServerError: 500 Internal Server Error
from /home/dlweber/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rest-client-1.7.3/lib/restclient/abstract_response.rb:48:in `return!'
Passing this ticket to someone else, because my dev environment will not allow debugging with binding.pry in the post method.
I got pry working, only by adding 'pry' to the standard gem dependencies (outside the development group). The dependency management for a rails engine is a bit different from an app; see http://edgeguides.rubyonrails.org/engines.html#other-gem-dependencies
This guide documentation indicates that development deps for an engine are only loaded when using the test app; as they say, "The development dependencies for the gem will only be used when the tests for the engine are running." So, when I run rake triannon:server_jetty
it never loads pry
when it is a dev dependency.
This was solved by wrapping the post data with additional params, i.e.
post_data = {
"commit" => "Create Annotation",
"annotation" => { "data" => oa.to_jsonld_oa }
}
Ran triannon using
rake triannon:server_jetty
and the console trace contains:The POST was done with RestClient, using:
where the
oa_jsonld
data is an open annotation with an OA context (in full, not as a URI), e.g.Without the OA context, the annotation has the following json representation: