Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
unmanaged extension : to process List of json strings
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Shireesh  
View profile  
 More options Oct 1 2012, 11:05 am
From: Shireesh <ashirees...@gmail.com>
Date: Mon, 1 Oct 2012 08:05:24 -0700 (PDT)
Local: Mon, Oct 1 2012 11:05 am
Subject: unmanaged extension : to process List of json strings

Hi,

i wrote an unmanaged plugin which accepts List<Strings> as input.

@javax.ws.rs.Path("/process-json")
public class Process{
@POST
public final Response processJson(final List<String> listOfJson){
for(String json : listOfJson)
{
 processJsonString(json);

}
}
}

and iam invoking this from RESTClient

POST http://localhost:7474/ext/unmanaged/process-json
Body : [{node1:[{"key1":1}]}]
Content-Type : "application/json"

But iam getting the following exception

HTTP/1.1 415 Unsupported Media Type


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tero Paananen  
View profile  
 More options Oct 1 2012, 11:31 am
From: Tero Paananen <teropaana...@gmail.com>
Date: Mon, 1 Oct 2012 11:31:46 -0400
Local: Mon, Oct 1 2012 11:31 am
Subject: Re: [Neo4j] unmanaged extension : to process List of json strings

> @javax.ws.rs.Path("/process-json")
> public class Process{
> @POST
> public final Response processJson(final List<String> listOfJson){
> for(String json : listOfJson)
> {
>  processJsonString(json);
> }
> }
> }

Annotate processJson with:

@Consumes(MediaType.APPLICATION_JSON)

import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType; // "application/json"

-TPP


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shireesh  
View profile  
 More options Oct 2 2012, 12:07 am
From: Shireesh <ashirees...@gmail.com>
Date: Mon, 1 Oct 2012 21:07:05 -0700 (PDT)
Local: Tues, Oct 2 2012 12:07 am
Subject: Re: [Neo4j] unmanaged extension : to process List of json strings

Thanks for the reply Tero,

I already tried with @Consumes annotation, but got the same exception.

And as per the documentation,
If we do not mention any MIME Type
"By default, a resource class can respond to and produce all MIME media
types of representations specified in the HTTP request and response
headers."

So does it mean it will very well accept Json ?

Any inputs are most welcomed.

Thanks,
Shireesh.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Neubauer  
View profile  
 More options Oct 2 2012, 5:08 pm
From: Peter Neubauer <peter.neuba...@neotechnology.com>
Date: Tue, 2 Oct 2012 23:08:05 +0200
Local: Tues, Oct 2 2012 5:08 pm
Subject: Re: [Neo4j] unmanaged extension : to process List of json strings
Shireesh,
just tried this:

@Path("/helloworld")
public class HelloWorldResource {
        private final GraphDatabaseService database;

        public HelloWorldResource(@Context GraphDatabaseService database) {
                this.database = database;
        }

        @GET
        @Consumes(MediaType.TEXT_PLAIN)
        @Produces(MediaType.TEXT_PLAIN)
        @Path("/{nodeId}")
        public Response hello(@PathParam("nodeId") long nodeId) {
                // Do stuff with the database
                return Response.status(Status.OK)
                                .entity(("Hello World, nodeId=" + nodeId).getBytes()).build();
        }

}

And the server complains rightfully for application/json, and not for
text/plain:

➜  server-examples git:(working) ✗ curl -H
"Content-Type:application/json" -v
http://localhost:7474/test/helloworld/1
* About to connect() to localhost port 7474 (#0)
*   Trying ::1...
* Connection refused
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 7474 (#0)

> GET /test/helloworld/1 HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:7474
> Accept: */*
> Content-Type:application/json

< HTTP/1.1 415 Unsupported Media Type
< Access-Control-Allow-Origin: *
< Content-Type: text/html; charset=iso-8859-1
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Length: 1408
< Server: Jetty(6.1.25)
<
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 415 Unsupported Media Type</title>
</head>
<body><h2>HTTP ERROR 415</h2>
<p>Problem accessing /test/helloworld/1. Reason:
<pre>    Unsupported Media Type</pre></p><hr /><i><small>Powered by
Jetty://</small></i><br/>

➜  server-examples git:(working) ✗ curl -H "Content-Type:text/plain"
-v http://localhost:7474/test/helloworld/1
* About to connect() to localhost port 7474 (#0)
*   Trying ::1...
* Connection refused
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 7474 (#0)

> GET /test/helloworld/1 HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:7474
> Accept: */*
> Content-Type:text/plain

< HTTP/1.1 200 OK
< Content-Length: 21
< Content-Type: text/plain
< Access-Control-Allow-Origin: *
< Server: Jetty(6.1.25)
<
* Connection #0 to host localhost left intact
Hello World, nodeId=1* Closing connection #0

------------

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Wanna learn something new? Come to http://graphconnect.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shireesh  
View profile  
 More options Oct 4 2012, 3:51 am
From: Shireesh <ashirees...@gmail.com>
Date: Thu, 4 Oct 2012 00:51:46 -0700 (PDT)
Local: Thurs, Oct 4 2012 3:51 am
Subject: Re: [Neo4j] unmanaged extension : to process List of json strings

Thankz Peter.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Neubauer  
View profile  
 More options Oct 4 2012, 7:21 pm
From: Peter Neubauer <peter.neuba...@neotechnology.com>
Date: Fri, 5 Oct 2012 01:21:00 +0200
Subject: Re: [Neo4j] unmanaged extension : to process List of json strings
Welcome!

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Neo4j 1.8 GA - http://www.dzone.com/links/neo4j_18_release_fluent_graph_literacy.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »