(Migrated) service request.payload response.payload

(This message has been automatically imported from the retired mailing list)

after a bit of trial and error I’ve determined that self.request.payload is
a hash
and self.response.payload is expected to be a string?? why does the input
and output api not consistent…

class PingPong(Service):
class SimpleIO:
input_required = (‘username’, ‘password’)
output_required = (‘username’, ‘password’)
def handle(self):
self.response.payload = dumps(self.request.payload)

I would expect the following to work not the above…

self.response.payload = self.request.payload

thanks

Ace

On 03/24/2014 12:39 AM, Jeffrey Gong wrote:

after a bit of trial and error I’ve determined that self.request.payload is
a hash
and self.response.payload is expected to be a string?? why does the input
and output api not consistent…

class PingPong(Service):
class SimpleIO:
input_required = (‘username’, ‘password’)
output_required = (‘username’, ‘password’)
def handle(self):
self.response.payload = dumps(self.request.payload)

Hi Jeffrey,

the API isn’t inconsistent, please have a look at this chapter

https://zato.io/docs/progguide/sio.html

in particular, the ‘How to produce the payload’ section

https://zato.io/docs/progguide/sio.html#how-to-produce-the-payload

In your example you have assigned a string to self.response.payload
hence it is a string. Had you assigned a dictionary it would have been a
dictionary.

On 03/24/2014 12:39 AM, Jeffrey Gong wrote:

after a bit of trial and error I’ve determined that self.request.payload is
a hash
and self.response.payload is expected to be a string?? why does the input
and output api not consistent…

class PingPong(Service):
class SimpleIO:
input_required = (‘username’, ‘password’)
output_required = (‘username’, ‘password’)
def handle(self):
self.response.payload = dumps(self.request.payload)

Hi Jeffrey,

the API isn’t inconsistent, please have a look at this chapter

https://zato.io/docs/progguide/sio.html

in particular, the ‘How to produce the payload’ section

https://zato.io/docs/progguide/sio.html#how-to-produce-the-payload

In your example you have assigned a string to self.response.payload
hence it is a string. Had you assigned a dictionary it would have been a
dictionary.