Encode message IDs correctly when using REST API

Use encodeURIComponent, not encodeURI