miha
(Miha)
June 11, 2019, 6:54pm
1
Hi
when you encode in base64 and you need to send this encoded data in json format, how to solve this if you get backslashes in encoded string? i guess you need to somehow escape them?
I do this:
b64.StdEncoding.EncodeToString( byte(string(body)))
And then I do marshal and send data via http.client, but i get error from server. I guess the issue are backslashes.
tnx
miha
NobbZ
(Norbert Melzer)
June 11, 2019, 7:15pm
2
There should be no backslash in Base64 encoded data…
Base64 on Wikipedia says, that valid characters are 0
-9
, a
-z
, A
-Z
, +
, and /
.
Aside of that, as you can see on the playground , json.Marshal
would escape the backslash for you.
miha
(Miha)
June 11, 2019, 7:49pm
3
hello, you are right, i was too quick! thank you for help!
i am having some strange issue with base64. If I send pdf or img files i get back from vendor server, 500, name too long.
But what is interesting is that if I send request (the same request) from Postman, than it works.
NobbZ
(Norbert Melzer)
June 11, 2019, 8:00pm
4
Then the request is probably not the same…
miha
(Miha)
June 11, 2019, 8:15pm
5
I dump the request, copy/paste to postman and send:(
NobbZ
(Norbert Melzer)
June 11, 2019, 8:34pm
6
Can you tell us how you do the request via go? Show some code?
system
(system)
Closed
September 9, 2019, 8:34pm
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.