- 时间戳错误
返回结果为{“error_code”:”400”,”error_message”:”com.alibaba.openapi.exception.request.RequestValidateException: Request is expired.”,”exception”:”com.alibaba.openapi.exception.request.RequestValidateException: Request is expired.”}
时间戳参数代表着访问api 的时间,只要传入了这个参数,那么每次访问时系统都会把这个参数与当前时间进行对比,如果二者相差超过了时间戳误差的话,就会报这个错误。 所以对于这个时间戳参数有三点需要注意:(1)首先要阅读api文档的系统级输入参数一节,看api 的访问是否需要时间戳,如果不需要就没有必要传入这个参数。(2)如果api 要求必须传入时间戳,那么最好是先进行时间校准然后再调用api。(3)时间戳的内容为时间的毫秒值,在java中转换方式为new Date().getTime(),其他编程语言也有类似的转换方式
时间戳校准方法:调用currentTime接口(http://gw.open.1688.com/openapi/param2/1/system/currentTime/{YOUR_APP_KEY})获取系统时间,然后跟本地取到的当前时间对比取二者的差,这样就得到了本地时间与阿里巴巴服务器的时间差;然后在调用api 时把当前时间加上这个时间差作为时间戳参数
- 缺少时间戳参数
返回结果为{“error_code”:”400”,”error_message”:”API need time stamp verify, so request must has aoptimestamp. “,”exception”:”API need time stamp verify, so request must has aoptimestamp. “}
原因是api 必须要有时间戳参数,但是调用时没有传入这个参数
- 调用api 时使用的appkey不存在或者未通过审核
返回结果为{“error_code”:”400”,”error_message”:”com.alibaba.openapi.exception.request.RequestValidateException: Invalid appKey, unsport appKey: xxx”,”exception”:”com.alibaba.openapi.exception.request.RequestValidateException: Invalid appKey, unsport appKey: xxx”}
对应的app不存在或者未通过审核
最后编辑:admin 更新时间:2022-06-29 17:49