开发者社区> 问答> 正文

阿里云OpenAPI 用户调用物联网平台的接口,报错怎么解决?

阿里云OpenAPI 用户调用物联网平台的接口: InvokeThingService, 报错怎么解决?报错:414 Request-URI Too Large
接口文档:https://help.aliyun.com/document_detail/69584.html?spm=a2c4g.69893.0.i2#reference-snk-mrz-wdb
com.aliyun.teautil.models.TeaUtilException: Error: convert to JSON, response is:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">







414 Request-URI Too Large



Sorry for the inconvenience.


Please report this message and include the following information to us.


Thank you very much!





URL:

https://*.aliyuncs.com:28443





Server:

pop-aliyun-com-region-cn-shanghai-iot-011193225225.et2





Date:

2023/07/13 13:41:12






Powered by Tengine
tengine



at com.aliyun.teautil.Common.readAsJSON(Common.java:214)

at com.aliyun.teaopenapi.Client.doRequest(Client.java:696)

at com.aliyun.teaopenapi.Client.callApi(Client.java:904)

at com.aliyun.iot20180120.Client.invokeThingServiceWithOptions(Client.java:6858)

at com.aliyun.iot20180120.Client.invokeThingService(Client.java:6863)

at com.sto.cloud.device.center.manage.external.iot.impl.IotThingServiceImpl.asynInvokeThingService(IotThingServiceImpl.java:44)

at com.sto.cloud.device.center.controller.api.DeviceIotController.sendAsynThingService$original$xIA2keWj(DeviceIotController.java:36)

at com.sto.cloud.device.center.controller.api.DeviceIotController.sendAsynThingService$original$xIA2keWj$accessor$Fq4VvKRa(DeviceIotController.java)

at com.sto.cloud.device.center.controller.api.DeviceIotController$auxiliary$jx4p8IJD.call(Unknown Source)

at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:94)

at com.sto.cloud.device.center.controller.api.DeviceIotController.sendAsynThingService(DeviceIotController.java)

at sun.reflect.GeneratedMethodAccessor840.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)

at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)

at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:893)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:807)

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1061)

at org.springframework.web.servlet.DispatcherServlet.

展开
收起
三分钟热度的鱼 2023-07-19 20:44:29 107 0
3 条回答
写回答
取消 提交回答
  • 北京阿里云ACE会长

    这个错误通常是由于请求的URL长度过长导致的,HTTP协议规定URL长度不能超过一定的限制,一般为2KB或4KB。这种情况下,您可以尝试以下解决方法:

    1.使用POST请求代替GET请求,将请求参数放到请求体中,避免URL过长。

    2.缩短请求URL,可以采用缩短网址等方式来实现。

    3.将请求参数进行压缩,可以采用Gzip等压缩方式来减小请求体大小。

    4.将请求参数进行分片,将请求分为多个小的请求,分别发送。

    2023-07-28 08:20:06
    赞同 展开评论 打赏
  • 可以考虑以下几点:

    1. 检查请求的URI长度:确保请求的URI长度不超过服务端所允许的最大长度限制。可以尝试缩短URI或减少参数数量。
    2. 通过POST请求发送参数:如果URI中的参数较多,可以考虑将这些参数放入请求体中,改用POST请求发送数据。
    3. 使用分页查询:如果您需要传递大量数据,最好使用分页查询的方式进行请求。通过在请求中指定页码和每页记录数来减少URI长度。
    4. 针对特定接口使用其他适当的方式:某些接口可能会提供其他方式来传递参数,例如,使用表单数据或JSON格式进行请求。
    2023-07-26 08:02:45
    赞同 展开评论 打赏
  • 这个报错是因为url太长了,1:找物联网的同学提需求。或者 2:点亮这里16441deb286294e68e8a800a63c37cbc.png
    把queries.put都改成body.put 此回答整理自钉群“OpenAPI 开发者门户 - 值班服务群2群”

    2023-07-19 20:56:45
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里云云原生 Serverless 技术实践营 PPT 演讲 立即下载
阿里云产品十月刊 立即下载
基于阿里云构建博学谷平台实时湖仓 立即下载