You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Dan Haywood <da...@haywood-associates.co.uk> on 2014/04/02 07:58:02 UTC

Re: Problem Persisting an entity via Isis

Hi Ola,
I see you asked this on SO also [1] and then self-answered that you have a
workaround.  So I presume this is no longer an issue for you.

But to answer it here: I think the error you're getting back is pretty
clear: "value" needs to be a string, not a JSON object.  You'll need to
convert the JSON to a string within your javascript, see for example
JSON.stringify(), [2]

Dan

[1]
http://stackoverflow.com/questions/22766621/angularjs-json-isis-cant-retrieved-json-data-in-restful-object-server-as-stri
[2] http://stackoverflow.com/questions/3593046/jquery-json-to-string



On 31 March 2014 14:52, Tomoloju, Ola <ol...@atos.net> wrote:

> Good day Dan,
>
>                 I am going working on option highlighted below .i.e define
> the last parameter as a simple string, and then do the parsing of the JSON
> server-side within your action. But I am getting the following error.
>
>
>
> "invalidReason":"Failed to parse representation as value of type
> 'String'"},"x-ro-invalidReason":"Basket Item is mandatory"}
>
>
>
> JSON Request sent to RO Server
>
> var basketItem=               {  X:x1, y:y1 };
>
>
>
>                                 var basketItemByStop=
>
>                                 {
>
>
>
>                                                                 sessionId
> : {
>
>
>       id : "sessionId",
>
>
>       memberType : "property",
>
>
>       value : '3432345ADC'
>
>                                                                 },
>
>                                                                 customerId
> : {
>
>
>       id : "customerId",
>
>
>       memberType: "property",
>
>
>       value : '123456'
>
>                                                                 },
>
>                                                                 email : {
>
>
>       id : "email",
>
>
>       memberType : "property",
>
>
>       value : "x.y@x.net"
>
>                                                                 },
>
>                                                                 basketItem
> : {
>
>
>       "id" : "basketItem",
>
>
>       "memberType" : "property",
>
>
>       "format" : "string",
>
>
>       "extensions" : {"x-isis-format" : "string"},
>
>
>       "value" : basketItem
>
>                                                                 }
>
> };
>
>
>
> My action method defintion
>
>
> @Bookmarkable
>     @ActionSemantics(Of.IDEMPOTENT)
>     @MemberOrder(sequence = "1")
>     @Named("View Basket - rich client")
>     @PublishedAction
>     public final ShoppingBasket getBasket(
>             @Named("Session ID") final String sessionID,
>             @Named("Customer ID") final String customerID,
>             @Named("Email") final String email,
>
>             @Named("Basket Item") final String newTravelCardDetailsJSON) {
>
> }
>
>
>
> The main problem is the newTravelCardDetailsJSON parameter is coming
> across as [object object] in the method and using toString() does not
> convert it to a normal string.
>
> I need it as a normal human readable json and pass it to my Jackson JSON
> parser for further processing.
>
> Please, how to a go about it this. Setting the format in my angular
> controller script above is not working.
>
>

RE: Problem Persisting an entity via Isis

Posted by "Tomoloju, Ola" <ol...@atos.net>.
Yes, Dan.
Thanks.


Ola Tomoloju 



-----Original Message-----
From: Dan Haywood [mailto:dan@haywood-associates.co.uk] 
Sent: Wednesday, April 02, 2014 6:58 AM
To: users
Subject: Re: Problem Persisting an entity via Isis

Hi Ola,
I see you asked this on SO also [1] and then self-answered that you have a workaround.  So I presume this is no longer an issue for you.

But to answer it here: I think the error you're getting back is pretty
clear: "value" needs to be a string, not a JSON object.  You'll need to convert the JSON to a string within your javascript, see for example JSON.stringify(), [2]

Dan

[1]
http://stackoverflow.com/questions/22766621/angularjs-json-isis-cant-retrieved-json-data-in-restful-object-server-as-stri
[2] http://stackoverflow.com/questions/3593046/jquery-json-to-string



On 31 March 2014 14:52, Tomoloju, Ola <ol...@atos.net> wrote:

> Good day Dan,
>
>                 I am going working on option highlighted below .i.e 
> define the last parameter as a simple string, and then do the parsing 
> of the JSON server-side within your action. But I am getting the following error.
>
>
>
> "invalidReason":"Failed to parse representation as value of type 
> 'String'"},"x-ro-invalidReason":"Basket Item is mandatory"}
>
>
>
> JSON Request sent to RO Server
>
> var basketItem=               {  X:x1, y:y1 };
>
>
>
>                                 var basketItemByStop=
>
>                                 {
>
>
>
>                                                                 
> sessionId
> : {
>
>
>       id : "sessionId",
>
>
>       memberType : "property",
>
>
>       value : '3432345ADC'
>
>                                                                 },
>
>                                                                 
> customerId
> : {
>
>
>       id : "customerId",
>
>
>       memberType: "property",
>
>
>       value : '123456'
>
>                                                                 },
>
>                                                                 email 
> : {
>
>
>       id : "email",
>
>
>       memberType : "property",
>
>
>       value : "x.y@x.net"
>
>                                                                 },
>
>                                                                 
> basketItem
> : {
>
>
>       "id" : "basketItem",
>
>
>       "memberType" : "property",
>
>
>       "format" : "string",
>
>
>       "extensions" : {"x-isis-format" : "string"},
>
>
>       "value" : basketItem
>
>                                                                 }
>
> };
>
>
>
> My action method defintion
>
>
> @Bookmarkable
>     @ActionSemantics(Of.IDEMPOTENT)
>     @MemberOrder(sequence = "1")
>     @Named("View Basket - rich client")
>     @PublishedAction
>     public final ShoppingBasket getBasket(
>             @Named("Session ID") final String sessionID,
>             @Named("Customer ID") final String customerID,
>             @Named("Email") final String email,
>
>             @Named("Basket Item") final String 
> newTravelCardDetailsJSON) {
>
> }
>
>
>
> The main problem is the newTravelCardDetailsJSON parameter is coming 
> across as [object object] in the method and using toString() does not 
> convert it to a normal string.
>
> I need it as a normal human readable json and pass it to my Jackson 
> JSON parser for further processing.
>
> Please, how to a go about it this. Setting the format in my angular 
> controller script above is not working.
>
>