HTTP表单方式提交 - nxtele/http-api-document-en GitHub Wiki

大部分 NXcloud 的接口都是以这种方式提交的。

  • 需要设置 HTTP METHOD 为 POST
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("POST");
  • 需要添加 Content-Type: application/x-www-form-urlencoded
    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  • 请注意对提交的字段做正确的 urlencode
    String body = "phone=8411111111&content=" + URLEncoder.encode("您的 短信内容 ,您的 短链内容", "UTF-8") + "&.....";

一个使用 postman 提交的示例截图

使用postman截图