入库抛出request url to long
追寻十四 发布于2017-12 浏览:1450 回复:2
0
收藏

商品检索图库管理 在入库的时候,抛出request url to long 的错误,图片的大小大多数都在15k之内,有什么办法避免这个错误。

收藏
点赞
0
个赞
共2条回复 最后由追寻十四回复于2017-12
#3追寻十四回复于2017-12

找到方法了,将image参数写入requsetStream并用UrlEncode编码:

 public static string PostData(string image_file_path, string brief, string class_id1, string class_id2, string Url)
        {
            WebRequest hr = HttpWebRequest.Create(Url);
            hr.Method = "POST";
            hr.ContentType = "application/x-www-form-urlencoded";
            string requestData = string.Empty;
            requestData = "image=" + HttpUtility.UrlEncode(Tools.ImageFilePathToBase64(image_file_path))
                + "&brief=" + brief
                + "&class_id1=" + class_id1
                + "&class_id2=" + class_id2;


            byte[] data = System.Text.Encoding.ASCII.GetBytes(requestData);
            hr.ContentLength = data.Length;
            using (Stream reqStream = hr.GetRequestStream())
            {
                reqStream.Write(data, 0, data.Length);

                reqStream.Close();
            }
            System.Net.WebResponse response = hr.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
            string ReturnVal = reader.ReadToEnd();
            reader.Close();
            response.Close();

            return ReturnVal;
        }
0
#2用户已被禁言回复于2017-12

这个错误应该不是接口返回的吧。

你是什么语言?什么开发平台?什么方式调用(API|SDK)?如果是接口返回的错误。请原文内容发出

1
TOP
切换版块