If you wanna receive the JSON payload of a POST request in TG, you could:
- use a RestController
- into the RestController add the post method that will handle POST request
- add the decode_params decorator to that method
@expose()
@decode_params('json')
def post(self, *args, **kw):
print(kw['name'])
print(kw['breed'])
I would suggest you also to add a validator for the input, since you can
not usually trust incoming data.
Il giorno venerdì 30 novembre 2018 20:49:33 UTC+1, Jorge Macias ha scritto:
>
> Hello.
> I'm using the RestController to read a post from another site. Using
> postman (image below) the params are received pretty fine with the
> turbogears RestController.
>
> [image: Screen Shot 2018-11-30 at 7.32.25 PM.png]
>
>
>
> In the other hand... if i tried to post with the content-type
> (application/json)
>
>
> [image: Screen Shot 2018-11-30 at 7.39.24 PM.png]
>
>
> Including the body in a json form (image below). Turbogears with a
> restfull controller doesn't receive any data. It's possible to receive this
> kind of post with turbogears??
>
> Can any body guide me what i can i do? I know that this post works 'cause
> i received perfectly with a flask app using req_data = request.get_json()
>
> But in turbogears is possible?
>
>
> Thanks in advance..
>
>
>
>
> [image: Screen Shot 2018-11-30 at 7.38.54 PM.png]
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.