无法对软层REST URI中的对象过滤器进行URL编码{}的编码 [英] Unable to URL encode { } for object filters in softlayer REST URI

查看:119
本文介绍了无法对软层REST URI中的对象过滤器进行URL编码{}的编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Rest调用Get方法,并且我的URI包含{}用于Softlayer中的对象过滤器.我已经为{和%7D为}使用了%7B,但是却得到了java.net.URISyntaxException.

I am calling a Get method through Rest and my URI contains { } for object filters in Softlayer. I have used %7B for { and %7D for }, but I get java.net.URISyntaxException.

URI也包含@,我已将其替换为%40.这正在工作.我正在使用http客户端执行我的Rest Call.不管有没有URL编码,URI都能在Postman上正常工作.

The URI also contains @ which I have replaced with %40. This is working. I am using http Client to execute my Rest Call. The URI works fine on Postman, both with and without URL Encoding.

推荐答案

这里有两种跳过或处理@的方法:

Here two way to skip or handle @:

另一种跳过特殊字符的方法是,在任何这些字符的开头都使用"\",这里是一个示例:

Another way to skip special characters would be, using "\" at the start from any of these chars, here an example of this:

此外,有必要跳过 {}:((objectFilters中的特殊字符)),如果您继续遇到异常,请提供示例或确切的代码,您正在尝试,以寻求进一步的帮助

Also, it's necessary to skip {}": (special chars in objectFilters), if you are continue hitting with the exception, would be great if you could provide an example or the exactly code that you are trying, for further assistance

以下是 dal05 数据中心的请求:

Here a rest request for dal05 datacenter:

https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests?objectMask=mask%5Bid%2Chostname%5D&objectFilter=%7B%22virtualGuests%22%3A%7B%22datacenter%22%3A%7B%22name%22%3A%7B%22operation%22%3A%22dal05%22%7D%7D%7D%7D

这篇关于无法对软层REST URI中的对象过滤器进行URL编码{}的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆