Unable to URL encode { } for object filters in softlayer REST URI

末鹿安然 提交于 2019-12-12 01:13:43

问题


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.

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.


回答1:


Here two way to skip or handle @:

  • how is '@' handled in the softlayer Rest calls

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

  • SoftLayer getUsers by userStatusID

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


How to get Virtual Guests for a specific datacenter

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


来源:https://stackoverflow.com/questions/42923676/unable-to-url-encode-for-object-filters-in-softlayer-rest-uri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!