How can I use hexadecimal metadata in any JSON-based API when hex is not supported by JSON?

+4 votes


While I am specifically trying to use Savoir, the Python API, this is a general question for the JSON-based request APIs. How do I pass the metadata argument to the function call? A sample call would look like:

api.sendwithmetadata('16T5dDM5TQRP1SQ2o86iWD1K6gCr8PV1231232' '{"asset1":1}', '48692066726f6d204d756c7469436861696e21')

But when I convert the hex argument to a decimal in order to make it JSON serializable, I get a parse error. If I leave it as is, I get an error saying expected real, got str. I've looked into encoding and decoding, but that has not solved the issue. What would be the appropriate way to make this API call, ideally in Python?

Thank you in advance.

asked Aug 16, 2016 by atsev

1 Answer

+2 votes
If you're using the API parameters in the correct order, any hexadecimal data is passed as a string, where the individual characters are the hexadecimal representation.

Your problem above appears to be in the second parameter, where you're passing the JSON representation of an object instead of the object (which presumably your Python library converts to JSON later on).
answered Aug 16, 2016 by MultiChain
Thank you - this worked perfectly!
I am having the same issue. Could you post the solution to your problem?