You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geode.apache.org by Real Wes Williams <Th...@outlook.com> on 2016/06/09 22:05:36 UTC
REST API, Gfsh and PDX Serialization
Is there any combination of settings where I can insert JSON objects into GFSH and have them read via the REST API? All works well when I both put and get via Swagger but I can’t put via Gfsh and get via Swagger due to Pdx serialization. Is there a way to put JSON via GFSH such that it can be read via the REST API? Or does it require a load program?
THIS DOES NOT WORK - Put JSON object via GFSH and Get via Swagger UI
gfsh> put —region=Orders --key=“AAPL" --value=(“symbol”:"AAPL”,"shares”:"1000") --value-class=io.pivotal.domain.Order
This puts the Order into the Orders region as an Order and not as a PdxInstanceImpl
And then in the Swagger UI
GET http://192.168.0.3:7070/gemfire-api/v1/Orders/AAPL
{
"cause": "Could not write JSON: Requested data could not convert into REST format[JSON] ; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Requested data could not convert into REST format[JSON] “
}
THIS WORKS - Put JSON object via Swagger and Get via Swagger
POST http://192.168.0.3:7070/gemfire-api/v1/Orders?key=AAPL
Value: {“symbol”:"AAPL”,"shares”:"1000"}
This puts the Order into the Orders region as a PdxInstanceImpl and not as an Order
GET http://192.168.0.3:7070/gemfire-api/v1/Orders/AAPL
Response:
{
“symbol": “AAPL",
“shares": “1000
}
Re: REST API, Gfsh and PDX Serialization
Posted by Mark Secrist <ms...@pivotal.io>.
Hi Wes,
I think the REST interface can only deal with PDX serialized objects,
which is why you are seeing the behavior you are. There isn't a mechanism
to introspect the Order object to pull out fields & values. PDX makes this
easy since the serialized object is already stored that way.
On Thu, Jun 9, 2016 at 4:05 PM, Real Wes Williams <Th...@outlook.com>
wrote:
>
> Is there any combination of settings where I can insert JSON objects into
> GFSH and have them read via the REST API? All works well when I both put
> and get via Swagger but I can’t put via Gfsh and get via Swagger due to Pdx
> serialization. Is there a way to put JSON via GFSH such that it can be
> read via the REST API? Or does it require a load program?
>
> *THIS DOES NOT WORK - Put JSON object via GFSH and Get via Swagger UI*
>
> gfsh> put —region=Orders --key=“AAPL"
> --value=(“symbol”:"AAPL”,"shares”:"1000")
> --value-class=io.pivotal.domain.Order
>
> This puts the Order into the Orders region as an Order and not as a
> PdxInstanceImpl
>
> And then in the Swagger UI
> GET http://192.168.0.3:7070/gemfire-api/v1/Orders/AAPL
>
> { "cause": "Could not write JSON: Requested data could not convert into
> REST format[JSON] ; nested exception is
> com.fasterxml.jackson.databind.JsonMappingException: Requested data could
> not convert into REST format[JSON] “ }
>
>
>
> *THIS WORKS - Put JSON object via Swagger and Get via Swagger*
>
> POST http://192.168.0.3:7070/gemfire-api/v1/Orders?key=AAPL
>
> Value: {“symbol”:"AAPL”,"shares”:"1000"}
>
> This puts the Order into the Orders region as a PdxInstanceImpl and not as
> an Order
>
>
> GET http://192.168.0.3:7070/gemfire-api/v1/Orders/AAPL
>
> Response:
> { “symbol": “AAPL", “shares": “1000
> }
>
>
>
--
*Mark Secrist | Sr Manager, **Global Education Delivery*
msecrist@pivotal.io
970.214.4567 Mobile
*pivotal.io <http://www.pivotal.io/>*
Follow Us: Twitter <http://www.twitter.com/pivotal> | LinkedIn
<http://www.linkedin.com/company/pivotalsoftware> | Facebook
<http://www.facebook.com/pivotalsoftware> | YouTube
<http://www.youtube.com/gopivotal> | Google+
<https://plus.google.com/105320112436428794490>