nk.httpRequest get bytes file and the body is convert to unexpected string

nk.httpRequest get bytes file and the body is convert to unexpected string

how could we convert it back to a Byte array or buffer array?

for example:

"\n�\u0002\n\u00011\u0018\u0001\"\u001dxxxxx@xxx.com(\u00012Ghttps://xxx.xxx.xxx.com/cps/{0}/cpsconfig-{1}.b

this is the string we got in the body
seem like the \n \u0002 is converted from the byte file.

what the encoding function here? how we can convert it back to byte in javascript runtime?

seems like this is the code for the response body handle:

do you think we should add an option for the httpRequest to customise the encoding method for the body?

for example: support base64 encoding for bytes?

Hello @mengxin,

Have you tried using the function nk.stringToBinary() on the returned body string? It should return an ArrayBuffer, although if the string is not UTF-8 encoded this might not work.

1 Like

thanks, it works!