Check if stream exists before publishing

+1 vote

Dear Multichain Team,

I'm using JSON-RPC API command "liststreams(`stream-name`)" to check if a stream with a specific name exists. If the stream exists I get an error (it is expected of course):

Error! Status code: 500

Text: {"result":null,"error":{"code":-708,"message":"Stream with this name not found: stream-name"},"id":1}

Json: {'result': None, 'error': {'code': -708, 'message': 'Stream with this name not found: stream-name'}, 'id': 1}

Is it possible to catch the above error? I was thinking to check whether the stream exists, if not create it and then publish an object, or else publish directly.

Many thanks!

asked May 22, 2018 by anonymous

1 Answer

0 votes
Yes, you can certainly catch the above error, at the application level. Just make your code act differently depending on whether you receive an error or not. Are you looking for something more than this?
answered May 23, 2018 by MultiChain
...