decode base64 httpwebresponse c# - 返回日语



我正在使用SSIS脚本组件来执行Web API的C#代码,该api正在向我返回一个值为base64 base64编码字节的值。

实际返回值是一个编码的JSON字符串,我随后需要进行估算和输出。

我正在使用以下C#尝试解码响应。

foreach (Attachment atch in rptOutputResponse.Response.attachments)
        {
            RptAttachmentsBuffer.AddRow();
            RptAttachmentsBuffer.AppId = rptOutputResponse.Response.appId;
            RptAttachmentsBuffer.Type = atch.type;
            RptAttachmentsBuffer.Name = atch.name;
            RptAttachmentsBuffer.ContentType = atch.contentType;
            byte[] rptConRaw = Encoding.UTF8.GetBytes(atch.content);
            String s = Convert.ToBase64String(rptConRaw);
            byte[] newbytes = Convert.FromBase64String(s);
            System.Windows.Forms.MessageBox.Show(BitConverter.ToString(newbytes));
            RptAttachmentsBuffer.ReportContent.AddBlobData(newbytes);
        }

预期的结果看起来像这样。

{"Applications":{"Application":{"AppID":2891426,"ReportID":4160202,"AppReference":"Taplin 12-Oct-16 10:37:02AM","CreateDT":"2016-10-12 10:37:23.3500000","ClientName":"GoGetta Brisbane","StoreName":"Brokers","Email":"","StoreCode":"GGT08","AppShortReference":"02","ClientNameShort":"GGT Bris","StoreNameShort":"GGT08","VerifyEmployer":null,"VerifyAmount":null,"VerifyFrequency":null,"VerifyWeekday":null,"LocalityCode":"en_AU","TemplateReportID":12,"daysRange":90,"templateReportName":"Enhanced Income Liabilities Full Report","Accounts":{"Account":[{"AccountID":4829641,"AccountNumber":"17-986-7500","AccountType":"savings","AccountName":"XXXXXXXXXXXX7500","AccountHolder

但是,当输出到我的桌子时,它将通过日语进行。我在做什么错?

请尝试以下内容:

foreach (Attachment atch in rptOutputResponse.Response.attachments)
{
    RptAttachmentsBuffer.AddRow();
    RptAttachmentsBuffer.AppId = rptOutputResponse.Response.appId;
    RptAttachmentsBuffer.Type = atch.type;
    RptAttachmentsBuffer.Name = atch.name;
    RptAttachmentsBuffer.ContentType = atch.contentType;
    byte[] newbytes = Convert.FromBase64String(atch.content);
    string json = Encoding.UTF8.GetString(newbytes);
    System.Windows.Forms.MessageBox.Show(json);
    RptAttachmentsBuffer.ReportContent.AddBlobData(newbytes);
}

最新更新