文档中心 > FAQ(已废弃)

Common Error

更新时间:2021/12/10 访问次数:563

Error:414 Request-URI Too Large(how to use post method to send request param)

if you put all the params into request uri and the param is very large, the error occurs. So, in case of the param is excessively long, you should use HTTP POST method. Actually, we recommend you always use the http POST method, and put all params into request entity rather than uri. Here is the sample code writen in java:


// build request parameters
Map<String, String> params = new HashMap<>();

// add public params
params.put("method", "aliexpress.solution.product.post");
params.put("app_key", TestAccount.TINY_tr1529165059esie.getAppKey());
params.put("session", TestAccount.TINY_tr1529165059esie.getAccessToken());
params.put("timestamp", LocalDateTime.now().format(
    DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
));
params.put("format", "json");
params.put("v", "2.0");
params.put("sign_method", Constants.SIGN_METHOD_HMAC);

// add "aliexpress.solution.product.post" api specific params
params.put("post_product_request", IOUtils.toString(PostProductDemo.class.getClassLoader().getResourceAsStream(
    "simple_product.json"), "UTF-8"));

// compute sign
// sign computation method reference doc: https://developers.aliexpress.com/en/doc.htm?spm=a219a.7386653.0.0.6ee89b71jEC8aA&docId=108974&docType=1
String sign = signTopRequest(params, TestAccount.TINY_tr1529165059esie.getAppSecret(), Constants.SIGN_METHOD_HMAC);

// add sign to params
params.put("sign", sign);

// fill the http post entity
List<NameValuePair> urlParameters = new ArrayList<>();
for (Map.Entry<String, String> e : params.entrySet()) {
    urlParameters.add(new BasicNameValuePair(e.getKey(), e.getValue()));
}

// construct a http post object
HttpPost post = new HttpPost("https://api.taobao.com/router/rest");
post.setEntity(new UrlEncodedFormEntity(urlParameters));

// construct a http client
CloseableHttpClient httpClient = HttpClients.createDefault();

// send post request
CloseableHttpResponse response = httpClient.execute(post);


FAQ

关于此文档暂时还没有FAQ
返回
顶部