2016-08-08 32 views
0

我准备了一个API,并且我想用json发布发送一个特定数据。某些角色没有发布Json Post - 获得500个响应

我的代码在使用Fiddler或网站端工作正常。

但问题是为什么有些角色没有发送,当我们使用Android版本作为客户端设备时。

例如:

字符串= “mn✈” //正确任何设备上(机器人,站点,提琴手,...)

串B = “mn✉” //纠正除(android)//获得500个响应外的任何设备

String requestURL = Utils.SERVER_URL + "PostJsonFeatures"; 
      HttpURLConnection conn = (HttpURLConnection) new URL(requestURL).openConnection(); 
      conn.setReadTimeout(15000); 
      conn.setConnectTimeout(15000); 
      conn.setRequestMethod("POST"); 
      conn.setDoInput(true); 
      conn.setDoOutput(true); 
      conn.setRequestProperty("Content-Type", "application/json"); 
      JSONObject postDataParams = new JSONObject(); 
      postDataParams.put("Features", getAttributes()); 
      postDataParams.put("productId", productId); 
      postDataParams.put("groupId", catId); 
      postDataParams.put("brandId", PrefManager.getInstance(context).getCompanyId()); 
      postDataParams.put("languageId", PrefManager.getInstance(context).getLanguageApi()); 

      DataOutputStream printout = new DataOutputStream(conn.getOutputStream()); 
      printout.write(postDataParams.toString().getBytes()); 
      printout.flush(); 
      printout.close(); 
+0

把你的代码在这里 – Developer

+0

@Singh它会编辑 – dan

+0

而在网页API – Developer

回答

0

您可以解码为字符串并通过url传递。

String parseString = URLDecoder.decode(URLEncoder.encode(myString, "UTF-8"), "ISO-8859-1");