What is the correct format for the API SurveyQuestionImage.Data field?

允我心安 提交于 2019-12-02 04:07:29
Good Lux

The data needs to be base64 encoded and also "urlsafe" or "websafe" depending on what language you are using. (python and java, respectively)

In other words, you'll need to first base64 encode then:

Web safe encoding uses '-' instead of '+', '_' instead of '/'

Hope this helps!

For c# users, check out this technique for making websafe b64:

How to achieve Base64 URL safe encoding in C#?

For .net users, look at the comments in this question:

Converting string to web-safe Base64 format

And also this link for more info about .net specific options for encoding:

http://www.codeproject.com/Tips/76650/Base-base-url-base-url-and-z-base-encoding


And to specifically answer the original poster, try this for converting your byte array to a string.

    public static string ToBase64ForUrlString(byte[] input)
    {
        StringBuilder result = new StringBuilder(Convert.ToBase64String(input).TrimEnd('='));
        result.Replace('+', '-');
        result.Replace('/', '_');
        return result.ToString();
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!