{"code":10001,"message":"InvalidArgument","hint":"","extra":""},请教一下这个原因是什么问题造成的呢,你们这接口始终调不通

阅读次数 1

image.png

body内容如下: {"url":"https://htyc-dev.oss-cn-hangzhou.aliyuncs.com/TEST/%E4%B8%AD%E6%A9%A1%EF%BC%88%E9%87%8D%E5%BA%86%EF%BC%89%E7%82%AD%E9%BB%91%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8001001%E5%8E%9F%E5%A7%8B%E8%AE%B0%E5%BD%95%E5%8D%95.docx?Expires=1743680654&OSSAccessKeyId=TMP.3KmXPHEAvaGTxDQYtceBtmNDDyV3SXAeSSWPYqxeZGVxhvwkhU1FZkEvMJji3h1YW4WcoooefDR2cF3eaKAh648cEgKpSJ&Signature=6rXtT73JjWPcPHmOoTI%2FrrmsKjA%3D","filename":"test.docx","show_comments":1}

2 Answers

截图是我的header参数,下面是body参数,body里面的filename字段是我随便写的一个名字,和我oss上的文件名字没有一致,这是导致问题的原因吗?

private static Request makePostHeader(RequestBody body, String rowBody, MediaType mediaType){ // 创建一个 SimpleDateFormat 对象,指定 RFC 1123 格式 SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); // 设置时区为 GMT
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

    // 格式化当前日期为 RFC 1123 格式
    Date now = new Date();
    String date = sdf.format(now);

// String date = "Wed, 23 Jan 2025 06:43:08 GMT"; String md5 = SecureUtil.md5(rowBody); String sha1 = SecureUtil.sha1(appKey + md5 + "application/json;charset=utf-8" + date); String authorization = "WPS-2:"+appId+":"+sha1;

    Request request = new Request.Builder()
            .url("https://solution.wps.cn/api/developer/v1/office/convert/to/pdf")
            .post(body)
            .addHeader("Date", date)
            .addHeader("Content-Md5", md5)
            .addHeader("Content-Type", "application/json;charset=utf-8")
            .addHeader("Authorization", authorization)
            .build();
    return request;
}

以上是我的代码逻辑