如何在放心的查询参数值中处理特殊字符 [英] how to handle Special character in query param value in Rest assured

查看:159
本文介绍了如何在放心的查询参数值中处理特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Rest Assured时,我正在努力处理查询参数值中的特殊字符.

I'm struggling with handling special character in query parameter value while working with Rest Assured.

在url中(如下所示),我必须传递用管道符号'|'分隔的值.我已将符号编码为值%7C,但是服务调用未给出匹配的响应,而是返回默认响应.

In url (as given below), I have to pass the value which is separated with pipe symbol '|'. I encoded symbol with value %7C however service call doesn't not give matching response instead returns default response.

http://localhost:8080/api/abc?Id = 7325860 %7C XYZ

有趣的是,相同的url可与任何浏览器其余客户端或其他基于Java的解决方案配合使用.

Interesting part is same url works fine with any browser rest client or other java based solution.

推荐答案

REST默认情况下,Assured确保对查询参数执行URL编码.您可以通过以下方式轻松禁用它:

REST Assured performs URL encoding for query parameters by default. You can easily disable it though:

given().urlEncodingEnabled(false).when().get("http://localhost:8080/api/abc?Id=7325860%7CXYZ");

有关更多信息,请参见文档.

See documentation for more info.

这篇关于如何在放心的查询参数值中处理特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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