You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Paul Benedict Jabines <ja...@gmail.com> on 2017/11/14 14:32:31 UTC

How to add an additional message in response? (RESTful)

I have a validateXxx() where I return a message "Name already exist." for
some conditions. I believe the response can be a json object. So how to add
another key - value in the response?

{
      ....
     "SomeMessage": "Name already exist."
      ....
}

Thanks,
- Paul

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Re: How to add an additional message in response? (RESTful)

Posted by Paul Benedict Jabines <ja...@gmail.com>.
Hi Andi,

I understand. Thanks.

On Wed, Nov 15, 2017 at 2:57 PM, Andi Huber <ah...@apache.org> wrote:

> Hi Paul,
> validateXxx() is regarded by the framework as a so called
> 'support-method'. Depending on your use-case, you could consider to instead
> write a dedicated 'action-method' that returns a Base64 encoded JSON string
> according to your needs, which you then decode on your RESTful client side.
>
> However, I'm not too confident, that this Base64 trick is best practice.
>
> Regards, Andi
>
> On 2017-11-14 15:32, Paul Benedict Jabines <ja...@gmail.com> wrote:
> > I have a validateXxx() where I return a message "Name already exist." for
> > some conditions. I believe the response can be a json object. So how to
> add
> > another key - value in the response?
> >
> > {
> >       ....
> >      "SomeMessage": "Name already exist."
> >       ....
> > }
> >
> > Thanks,
> > - Paul
> >
> > <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail>
> > Virus-free.
> > www.avast.com
> > <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
>



-- 
- Paul

Re: How to add an additional message in response? (RESTful)

Posted by Andi Huber <ah...@apache.org>.
Hi Paul,
validateXxx() is regarded by the framework as a so called 'support-method'. Depending on your use-case, you could consider to instead write a dedicated 'action-method' that returns a Base64 encoded JSON string according to your needs, which you then decode on your RESTful client side.

However, I'm not too confident, that this Base64 trick is best practice.

Regards, Andi

On 2017-11-14 15:32, Paul Benedict Jabines <ja...@gmail.com> wrote: 
> I have a validateXxx() where I return a message "Name already exist." for
> some conditions. I believe the response can be a json object. So how to add
> another key - value in the response?
> 
> {
>       ....
>      "SomeMessage": "Name already exist."
>       ....
> }
> 
> Thanks,
> - Paul
> 
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>