【问题标题】:java.lang.IllegalArgumentException :Invalid urijava.lang.IllegalArgumentException:无效的 uri
【发布时间】:2022-01-14 10:28:47
【问题描述】:

我正在尝试获取 uri 的响应,但每次我得到的都是错误消息“无效的 uri” 这是我尝试过的(代码 sn-p):

String sAttachURL = "https://rt4.de.company.com/gx/service/com.ibm.rqm.integration.service.IIntegrationService/resources/Electric_TM/executionworkitem?fields=feed/entry/content/executionworkitem/testplan[@href=\"rt4.de.company.com/gx/service/com.ibm.rqm.integration.service.IIntegrationService/resources/Electric_TM/testplan/urn:com.ibm.rqm:testplan:27\"]";
GetMethod method = new GetMethod(sAttachURL);

如果我在 RESTClient 中点击相同的 url,如果尝试触发这样的事情,响应也会正确:

String sAttachURLService = "https://rt4.de.company.com/gx/service";
GetMethod method = new GetMethod(sAttachURLService);

响应通过我的代码正确发出,但仅适用于 sAttachURL 它抛出错误不知道为什么我也觉得 [ ] 括号可能会在编码不确定时导致一些问题 谁能帮帮我

谢谢

【问题讨论】:

    标签: java url


    【解决方案1】:

    您是否尝试过对括号进行百分比编码? [ %5B 和 %5D ],所以在你的情况下:

    String sAttachURL = "https://rt4.de.company.com/gx/service/com.ibm.rqm.integration.service.IIntegrationService/resources/Electric_TM/executionworkitem?fields=feed/entry/content/executionworkitem/testplan%5B@href=\"rt4.de.company.com/gx/service/com.ibm.rqm.integration.service.IIntegrationService/resources/Electric_TM/testplan/urn:com.ibm.rqm:testplan:27\"%5D";
    

    【讨论】:

    • 感谢您解决我的问题,但我也尝试过,但仍然是同样的问题 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 2016-01-26
    • 2017-11-04
    • 2017-12-13
    • 1970-01-01
    相关资源
    最近更新 更多