Custom/Execute REST call mangling string

I'm presenting data to an outside party using a Custom/Execute REST procedure.  One of the data items is an id which needs to be padded with starting zeros, and be five characters, so for instance "1" should come across "00001".  That's easy enough to do in my stored procedure, which returns a varchar(5) of value "00001".  But when run through the REST Service, the value comes out as "1    " (a "1" with four " " after it).  Is there any kind of configuration I can do on my end to prevent this from happening?  Does anyone know why is it happening?

  • Don't know why it is happenning but I am assuming from the output you are getting that along the way it detects it as a number then converts it back to a char(5) padded variable.

    Until I saw the space padding at the end was going to suggest using char(5) rather than varchar(5) but the space padding seems to suggest it already honours that.

    Oddish suggestion but might work - would be to change the first 0 to 0 - which is the HTML character code for 0, just assuming that this would fool the bit that thinks it is a number so it doesn't convert it but that the side that downloads it would convert it back to a 0 - assuming this as they normally convert & etc 

    Mark

  • I've just discovered the source of this bug, and it is on our end.  I had forgotten that the value in question, while supplied by default in the local procedure, could also be passed in as a parameter, and it turned out that all users testing (myself included) had copied and pasted a REST parameter string including @org_id=1...and then this, presumably, would render as "1    " as a char(5).