List Assets returns a 500 status code when asset doesn't exist

+1 vote

I think this must be a recent change as I'm pretty sure listassets didn't do this in previous versions.  By returning a 500 most clients (mine included) assume a fatal error of some kind and abort the request.  This isn't great since I was checking for the existence of an asset as part of my processing which now fails!

This should return a 404 as not found for http consistency or 200 and empty as I'm not techniucally going a "GET", more a list with a filter, so 200 is probably more consistent.

Either way a 500 is a bit brutal :)




asked Apr 27, 2017 by marty

1 Answer

0 votes
Are you sure you're getting an HTTP 500 error, and not a -708 error inside the JSON-RPC response? The latter is the expected behavior, but perhaps there's a bug in there somewhere.
answered Apr 28, 2017 by MultiChain
I get both......

Here is the response:

  "result": null,
  "error": {
    "code": -708,
    "message": "Asset with this name not found: myAsset"
  "id": 1

but the http status code is 500 as well?
OK, thanks, certainly sounds like a bug. We'll look into it and fix it for the next beta release.
It turns out that almost all JSON-RPC errors are accompanied by an HTTP 500. If we had to design the API from scratch, we would do differently, but this behavior was inherited from Bitcoin Core and we prefer to maintain that backwards compatibility. We'll revisit the decision again in future if it becomes an issue for many users.