# Plugin and content type

**URL:** https://discuss.elastic.co/t/plugin-and-content-type/11139
**Category:** Elasticsearch
**Created:** [March 13, 2013, 4:52pm UTC](https://discuss.elastic.co/t/plugin-and-content-type/11139 "2013-03-13T16:52:31Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![eric\_sanford](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@eric\_sanford](https://discuss.elastic.co/u/eric_sanford)
#### Post date: [March 13, 2013, 4:52pm UTC](https://discuss.elastic.co/t/plugin-and-content-type/11139/1 "2013-03-13T16:52:31Z")

</div>

hello

i have a plugin that defines REST endpoints

when i use soap ui to hit the endpoints... soap ui says "Not JSON content"

when i run the same search against the default ES URL  
(i.e. [http://localhost:9210/scnprobldir3a/item/\_search](http://localhost:9210/scnprobldir3a/item/_search) ) rather than the  
URLs defined in the plugin, the JSON content is properly displayed

I guess my question is...

how do i set the content type when returning data from a plugin like so...

_channel.sendResponse(new StringRestResponse(OK, entity.toString()));_  
\*  
\*  
Thx !!!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [March 13, 2013, 4:58pm UTC](https://discuss.elastic.co/t/plugin-and-content-type/11139/2 "2013-03-13T16:58:21Z")

</div>

Hey,

please check the hiercharchy of the StringRestResponse, you will see it  
inherits from Utf8RestResponse, which defines its content-type.  
You may need to set it to "application/json" manually, or better use a  
another class, which extends AbstractRestResponse.

On Wed, Mar 13, 2013 at 5:52 PM, eric sanford  
[pcstechnologiesinc@gmail.com](mailto:pcstechnologiesinc@gmail.com)wrote:

> hello
> 
> i have a plugin that defines REST endpoints
> 
> when i use soap ui to hit the endpoints... soap ui says "Not JSON content"
> 
> when i run the same search against the default ES URL (i.e.  
> [http://localhost:9210/scnprobldir3a/item/\_search](http://localhost:9210/scnprobldir3a/item/_search) ) rather than the URLs  
> defined in the plugin, the JSON content is properly displayed
> 
> I guess my question is...
> 
> how do i set the content type when returning data from a plugin like so...
> 
> _channel.sendResponse(new StringRestResponse(OK, entity.toString()));_  
> \*  
> \*  
> Thx !!!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![eric\_sanford](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@eric\_sanford](https://discuss.elastic.co/u/eric_sanford)
#### Post date: [March 13, 2013, 5:12pm UTC](https://discuss.elastic.co/t/plugin-and-content-type/11139/3 "2013-03-13T17:12:03Z")

</div>

thanks !!

i looked at the hierarchy, and all type have a contentType() method.. but i  
dont see how i can set it (there is no setter)

On Wednesday, March 13, 2013 11:52:31 AM UTC-5, eric sanford wrote:

> hello
> 
> i have a plugin that defines REST endpoints
> 
> when i use soap ui to hit the endpoints... soap ui says "Not JSON content"
> 
> when i run the same search against the default ES URL (i.e.  
> [http://localhost:9210/scnprobldir3a/item/\_search](http://localhost:9210/scnprobldir3a/item/_search) ) rather than the URLs  
> defined in the plugin, the JSON content is properly displayed
> 
> I guess my question is...
> 
> how do i set the content type when returning data from a plugin like so...
> 
> _channel.sendResponse(new StringRestResponse(OK, entity.toString()));_  
> \*  
> \*  
> Thx !!!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![eric\_sanford](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@eric\_sanford](https://discuss.elastic.co/u/eric_sanford)
#### Post date: [March 13, 2013, 5:12pm UTC](https://discuss.elastic.co/t/plugin-and-content-type/11139/4 "2013-03-13T17:12:10Z")

</div>

On Wednesday, March 13, 2013 11:52:31 AM UTC-5, eric sanford wrote:

> hello
> 
> i have a plugin that defines REST endpoints
> 
> when i use soap ui to hit the endpoints... soap ui says "Not JSON content"
> 
> when i run the same search against the default ES URL (i.e.  
> [http://localhost:9210/scnprobldir3a/item/\_search](http://localhost:9210/scnprobldir3a/item/_search) ) rather than the URLs  
> defined in the plugin, the JSON content is properly displayed
> 
> I guess my question is...
> 
> how do i set the content type when returning data from a plugin like so...
> 
> _channel.sendResponse(new StringRestResponse(OK, entity.toString()));_  
> \*  
> \*  
> Thx !!!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![eric\_sanford](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@eric\_sanford](https://discuss.elastic.co/u/eric_sanford)
#### Post date: [March 13, 2013, 5:15pm UTC](https://discuss.elastic.co/t/plugin-and-content-type/11139/5 "2013-03-13T17:15:17Z")

</div>

i dont see how to set the content type. all types that implement  
RestResponse[http://rajish.github.com/api/elasticsearch/0.20.0.Beta1-SNAPSHOT/org/elasticsearch/rest/RestResponse.html](http://rajish.github.com/api/elasticsearch/0.20.0.Beta1-SNAPSHOT/org/elasticsearch/rest/RestResponse.html) seem  
to have a contentType() method, which appears to be a getter... i cant  
figure out how to set it

On Wednesday, March 13, 2013 11:58:21 AM UTC-5, Alexander Reelsen wrote:

> Hey,
> 
> please check the hiercharchy of the StringRestResponse, you will see it  
> inherits from Utf8RestResponse, which defines its content-type.  
> You may need to set it to "application/json" manually, or better use a  
> another class, which extends AbstractRestResponse.
> 
> On Wed, Mar 13, 2013 at 5:52 PM, eric sanford \<[pcstechno...@gmail.com](mailto:pcstechno...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > hello
> > 
> > i have a plugin that defines REST endpoints
> > 
> > when i use soap ui to hit the endpoints... soap ui says "Not JSON content"
> > 
> > when i run the same search against the default ES URL (i.e.  
> > [http://localhost:9210/scnprobldir3a/item/\_search](http://localhost:9210/scnprobldir3a/item/_search) ) rather than the URLs  
> > defined in the plugin, the JSON content is properly displayed
> > 
> > I guess my question is...
> > 
> > how do i set the content type when returning data from a plugin like so...
> > 
> > _channel.sendResponse(new StringRestResponse(OK, entity.toString()));_  
> > \*  
> > \*  
> > Thx !!!
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [March 13, 2013, 5:26pm UTC](https://discuss.elastic.co/t/plugin-and-content-type/11139/6 "2013-03-13T17:26:26Z")

</div>

Hey,

just override it in your own class then?

On Wed, Mar 13, 2013 at 6:15 PM, eric sanford  
[pcstechnologiesinc@gmail.com](mailto:pcstechnologiesinc@gmail.com)wrote:

> i dont see how to set the content type. all types that implement  
> RestResponse[http://rajish.github.com/api/elasticsearch/0.20.0.Beta1-SNAPSHOT/org/elasticsearch/rest/RestResponse.html](http://rajish.github.com/api/elasticsearch/0.20.0.Beta1-SNAPSHOT/org/elasticsearch/rest/RestResponse.html) seem  
> to have a contentType() method, which appears to be a getter... i cant  
> figure out how to set it
> 
> On Wednesday, March 13, 2013 11:58:21 AM UTC-5, Alexander Reelsen wrote:
> 
> > Hey,
> > 
> > please check the hiercharchy of the StringRestResponse, you will see it  
> > inherits from Utf8RestResponse, which defines its content-type.  
> > You may need to set it to "application/json" manually, or better use a  
> > another class, which extends AbstractRestResponse.
> > 
> > On Wed, Mar 13, 2013 at 5:52 PM, eric sanford [pcstechno...@gmail.com](mailto:pcstechno...@gmail.com)wrote:
> > 
> > > hello
> > > 
> > > i have a plugin that defines REST endpoints
> > > 
> > > when i use soap ui to hit the endpoints... soap ui says "Not JSON  
> > > content"
> > > 
> > > when i run the same search against the default ES URL (i.e.  
> > > [http://localhost:9210/\*\*scnprobldir3a/item/\_search](http://localhost:9210/**scnprobldir3a/item/_search)[http://localhost:9210/scnprobldir3a/item/\_search](http://localhost:9210/scnprobldir3a/item/_search)) rather than the URLs defined in the plugin, the JSON content is properly  
> > > displayed
> > > 
> > > I guess my question is...
> > > 
> > > how do i set the content type when returning data from a plugin like  
> > > so...
> > > 
> > > _channel.sendResponse(new StringRestResponse(OK, entity.toString()));_  
> > > \*  
> > > \*  
> > > Thx !!!
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 2:46am UTC](https://discuss.elastic.co/t/plugin-and-content-type/11139/7 "2017-07-06T02:46:38Z")

</div>


