talk@lists.collectionspace.org

WE HAVE SUNSET THIS LISTSERV - Join us at collectionspace@lyrasislists.org

View all threads

more REST object creation challenges

JS
Joe Slag
Thu, Mar 24, 2011 3:34 PM

Since Aron's tip of the other week on the proper URL for creating objects
via REST, I've been trying to replicate the example curl script's success
with a short python program. However, I'm running into some snags, and
wondered if anyone had any pointers.

You can see my sample program at https://gist.github.com/884070
When I run this, I get a 400 error. jboss/server/cspace/log/server.log
says:

ERROR [org.jboss.resteasy.core.SynchronousDispatcher] Failed executing POST
collectionobjects
org.jboss.resteasy.spi.BadRequestException: content-type was null and
expecting to extract a body
at
org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:131)

From looking at the packets sent by curl vs. those sent by this python

script, it does seem that curl includes the content-type header in the first
packet it sends, while the python script doesn't include it until the second
packet. I tried working around this by skipping the python mime libraries
and crafting the payload by hand, but that led to a series of MIME
validation errors from collectionspace, which made me think I was barking up
the wrong tree.

So, a few questions:

  • are people using the REST API to create objects with a different
    toolchain? any public examples?

  • might it be worth waiting for CS 1.5? According to the wiki, it won't be
    necessary to wrap create requests in MIME any more, which should make this
    quite a bit simpler.

  • For that matter, how hard would it be to get a nightly build running now?
    I don't see anything on the wiki other than installing released versions.

cheers,
Joe

Since Aron's tip of the other week on the proper URL for creating objects via REST, I've been trying to replicate the example curl script's success with a short python program. However, I'm running into some snags, and wondered if anyone had any pointers. You can see my sample program at https://gist.github.com/884070 When I run this, I get a 400 error. jboss/server/cspace/log/server.log says: ERROR [org.jboss.resteasy.core.SynchronousDispatcher] Failed executing POST collectionobjects org.jboss.resteasy.spi.BadRequestException: content-type was null and expecting to extract a body at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:131) >From looking at the packets sent by curl vs. those sent by this python script, it does seem that curl includes the content-type header in the first packet it sends, while the python script doesn't include it until the second packet. I tried working around this by skipping the python mime libraries and crafting the payload by hand, but that led to a series of MIME validation errors from collectionspace, which made me think I was barking up the wrong tree. So, a few questions: - are people using the REST API to create objects with a different toolchain? any public examples? - might it be worth waiting for CS 1.5? According to the wiki, it won't be necessary to wrap create requests in MIME any more, which should make this quite a bit simpler. - For that matter, how hard would it be to get a nightly build running now? I don't see anything on the wiki other than installing released versions. cheers, Joe
CM
Chris Martin
Thu, Mar 24, 2011 3:51 PM

I would state that is has been a lot easier to integrate since the
change to POX so it is well worth using 1.5

The App layers primary reason for existence is to integrate with the
service layer and deal with the complexities necessary in sending data
to them. Unfortunately my experience dealing with the Service Layer APIs
is all thr Java but I feel your pain and I am happy to share that pain
at anytime. And you are welcome to look into the App code to see what it
does with payloads etc. And I have just got blob file upload saving thr
the API but that complexity was mostly java being a pain with
fileuploads and boundaries and content-dispositions.

how hard is it to get the trunk code working? not too hard if you
already have a working service layer. You should be able to check it out
over your existing build and cross fingers it might all just work, but
don't quote me on that. I just usually dev against the
nightly.collectionspace service layer - which is fine if you don't need
to see any of the service layer errors - so probably not useful for you.

Good luck

Chris

On 24/03/2011 15:34, Joe Slag wrote:

Since Aron's tip of the other week on the proper URL for creating
objects via REST, I've been trying to replicate the example curl
script's success with a short python program. However, I'm running
into some snags, and wondered if anyone had any pointers.

You can see my sample program at https://gist.github.com/884070
When I run this, I get a 400 error. jboss/server/cspace/log/server.log
says:

ERROR [org.jboss.resteasy.core.SynchronousDispatcher] Failed executing
POST collectionobjects
org.jboss.resteasy.spi.BadRequestException: content-type was null and
expecting to extract a body
at
org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:131)

From looking at the packets sent by curl vs. those sent by this python
script, it does seem that curl includes the content-type header in the
first packet it sends, while the python script doesn't include it
until the second packet. I tried working around this by skipping the
python mime libraries and crafting the payload by hand, but that led
to a series of MIME validation errors from collectionspace, which made
me think I was barking up the wrong tree.

So, a few questions:

  • are people using the REST API to create objects with a different
    toolchain? any public examples?

  • might it be worth waiting for CS 1.5? According to the wiki, it
    won't be necessary to wrap create requests in MIME any more, which
    should make this quite a bit simpler.

  • For that matter, how hard would it be to get a nightly build running
    now? I don't see anything on the wiki other than installing released
    versions.

cheers,
Joe


Talk mailing list
Talk@lists.collectionspace.org
http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org

I would state that is has been a lot easier to integrate since the change to POX so it is well worth using 1.5 The App layers primary reason for existence is to integrate with the service layer and deal with the complexities necessary in sending data to them. Unfortunately my experience dealing with the Service Layer APIs is all thr Java but I feel your pain and I am happy to share that pain at anytime. And you are welcome to look into the App code to see what it does with payloads etc. And I have just got blob file upload saving thr the API but that complexity was mostly java being a pain with fileuploads and boundaries and content-dispositions. how hard is it to get the trunk code working? not too hard if you already have a working service layer. You should be able to check it out over your existing build and cross fingers it might all just work, but don't quote me on that. I just usually dev against the nightly.collectionspace service layer - which is fine if you don't need to see any of the service layer errors - so probably not useful for you. Good luck Chris On 24/03/2011 15:34, Joe Slag wrote: > Since Aron's tip of the other week on the proper URL for creating > objects via REST, I've been trying to replicate the example curl > script's success with a short python program. However, I'm running > into some snags, and wondered if anyone had any pointers. > > You can see my sample program at https://gist.github.com/884070 > When I run this, I get a 400 error. jboss/server/cspace/log/server.log > says: > > ERROR [org.jboss.resteasy.core.SynchronousDispatcher] Failed executing > POST collectionobjects > org.jboss.resteasy.spi.BadRequestException: content-type was null and > expecting to extract a body > at > org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:131) > > From looking at the packets sent by curl vs. those sent by this python > script, it does seem that curl includes the content-type header in the > first packet it sends, while the python script doesn't include it > until the second packet. I tried working around this by skipping the > python mime libraries and crafting the payload by hand, but that led > to a series of MIME validation errors from collectionspace, which made > me think I was barking up the wrong tree. > > So, a few questions: > > - are people using the REST API to create objects with a different > toolchain? any public examples? > > - might it be worth waiting for CS 1.5? According to the wiki, it > won't be necessary to wrap create requests in MIME any more, which > should make this quite a bit simpler. > > - For that matter, how hard would it be to get a nightly build running > now? I don't see anything on the wiki other than installing released > versions. > > cheers, > Joe > > > _______________________________________________ > Talk mailing list > Talk@lists.collectionspace.org > http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org
RM
Richard Millet
Thu, Mar 24, 2011 5:25 PM

See my comments/responses inline below.

From: talk-bounces@lists.collectionspace.org [mailto:talk-bounces@lists.collectionspace.org] On Behalf Of Joe Slag
Sent: Thursday, March 24, 2011 8:35 AM
To: talk@lists.collectionspace.org
Subject: [Talk] more REST object creation challenges

Since Aron's tip of the other week on the proper URL for creating objects via REST, I've been trying to replicate the example curl script's success with a short python program. However, I'm running into some snags, and wondered if anyone had any pointers.

You can see my sample program at  https://gist.github.com/884070 https://gist.github.com/884070

When I run this, I get a 400 error. jboss/server/cspace/log/server.log says:

ERROR [org.jboss.resteasy.core.SynchronousDispatcher] Failed executing POST collectionobjects

org.jboss.resteasy.spi.BadRequestException: content-type was null and expecting to extract a body

    at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:131)

From looking at the packets sent by curl vs. those sent by this python script, it does seem that curl includes the content-type header in the first packet it sends, while the python script doesn't include it until the second packet. I tried working around this by skipping the python mime libraries and crafting the payload by hand, but that led to a series of MIME validation errors from collectionspace, which made me think I was barking up the wrong tree.

So, a few questions:

  • are people using the REST API to create objects with a different toolchain? any public examples?

Besides ‘curl’, all the clients I know of are different variations of Java clients.  There is a RESTEasy-based Java client that we use to test the services and to perform some forms of data import.  There is the App layer that uses standard Java libraries classes to talk with the services and there is another payload-centric Java tool we use to perform additional testing of the services.  All of this code is available at https:source.collectionspace.org/collection-space/.

  • might it be worth waiting for CS 1.5? According to the wiki, it won't be necessary to wrap create requests in MIME any more, which should make this quite a bit simpler.

Yes, it might be worth using the v1.5 release instead.  Everything is just plain-old-XML so you may not encounter the problems you’re seeing in v1.3.

  • For that matter, how hard would it be to get a nightly build running now? I don't see anything on the wiki other than installing released versions.

cheers,

Joe

See my comments/responses inline below. From: talk-bounces@lists.collectionspace.org [mailto:talk-bounces@lists.collectionspace.org] On Behalf Of Joe Slag Sent: Thursday, March 24, 2011 8:35 AM To: talk@lists.collectionspace.org Subject: [Talk] more REST object creation challenges Since Aron's tip of the other week on the proper URL for creating objects via REST, I've been trying to replicate the example curl script's success with a short python program. However, I'm running into some snags, and wondered if anyone had any pointers. You can see my sample program at <https://gist.github.com/884070> https://gist.github.com/884070 When I run this, I get a 400 error. jboss/server/cspace/log/server.log says: ERROR [org.jboss.resteasy.core.SynchronousDispatcher] Failed executing POST collectionobjects org.jboss.resteasy.spi.BadRequestException: content-type was null and expecting to extract a body at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:131) >From looking at the packets sent by curl vs. those sent by this python script, it does seem that curl includes the content-type header in the first packet it sends, while the python script doesn't include it until the second packet. I tried working around this by skipping the python mime libraries and crafting the payload by hand, but that led to a series of MIME validation errors from collectionspace, which made me think I was barking up the wrong tree. So, a few questions: - are people using the REST API to create objects with a different toolchain? any public examples? Besides ‘curl’, all the clients I know of are different variations of Java clients. There is a RESTEasy-based Java client that we use to test the services and to perform some forms of data import. There is the App layer that uses standard Java libraries classes to talk with the services and there is another payload-centric Java tool we use to perform additional testing of the services. All of this code is available at https:source.collectionspace.org/collection-space/. - might it be worth waiting for CS 1.5? According to the wiki, it won't be necessary to wrap create requests in MIME any more, which should make this quite a bit simpler. Yes, it might be worth using the v1.5 release instead. Everything is just plain-old-XML so you may not encounter the problems you’re seeing in v1.3. - For that matter, how hard would it be to get a nightly build running now? I don't see anything on the wiki other than installing released versions. cheers, Joe
KG
Kasper Galschiot Markus
Thu, Mar 24, 2011 6:14 PM

Hi Joe,

  • For that matter, how hard would it be to get a nightly build running
    now? I don't see anything on the wiki other than installing released
    versions.

Off the top of my head, these are the steps that would be involved in
updating to trunk:

mkdir svc ui app
cd svc
svn co
https://source.collectionspace.org/collection-space/src/services/trunk/
cd trunk
mvn clean install -DskipTests
ant deploy create_db import

cd ../app
svn co
https://source.collectionspace.org/collection-space/src/application/trunk/svcapp/
cd svcapp
mvn clean install -DskipTests

cd ../ui
svn co https://source.collectionspace.org/collection-space/src/ui/trunk/
cd trunk
mvn clean install -DskipTests

Starting both servers now, should give you a trunk version of cspace.

Note that the above will clear the database, etc. To avoid this you can
exclude "create_db import", but this is risky if services have made any
changes to the database structure. Also you might want to do the
initialization of dropdowns, and maybe initialization of the sample
data, described in the install instructions.

Be aware that things might be broken in trunk - we try to keep it stable
enough to be able to develop on it, but it does break/behave weird
occasionally!

Hope that helped,

~Kasper

Hi Joe, > > - For that matter, how hard would it be to get a nightly build running > now? I don't see anything on the wiki other than installing released > versions. > Off the top of my head, these are the steps that would be involved in updating to trunk: mkdir svc ui app cd svc svn co https://source.collectionspace.org/collection-space/src/services/trunk/ cd trunk mvn clean install -DskipTests ant deploy create_db import cd ../app svn co https://source.collectionspace.org/collection-space/src/application/trunk/svcapp/ cd svcapp mvn clean install -DskipTests cd ../ui svn co https://source.collectionspace.org/collection-space/src/ui/trunk/ cd trunk mvn clean install -DskipTests Starting both servers now, should give you a trunk version of cspace. Note that the above will clear the database, etc. To avoid this you can exclude "create_db import", but this is risky if services have made any changes to the database structure. Also you might want to do the initialization of dropdowns, and maybe initialization of the sample data, described in the install instructions. Be aware that things might be broken in trunk - we try to keep it stable enough to be able to develop on it, but it does break/behave weird occasionally! Hope that helped, ~Kasper > cheers, > Joe > > > _______________________________________________ > Talk mailing list > Talk@lists.collectionspace.org > http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org