简体   繁体   English

REST api URL端点中的like参数

[英]Like parameter in REST api url endpoint

Is it possible to pass parameters with 'like' keyword in REST api endpoints. 是否可以在REST api端点中使用“ like”关键字传递参数。 Basically I'm trying to create an endpoint wherein I would query a db to get list of items based on '%name%'. 基本上,我正在尝试创建一个端点,在该端点中,我将查询数据库以获取基于'%name%'的项目列表。 The corresponding query in DB would be like: 数据库中的相应查询如下:

SELECT * FROM users WHERE user_id like "%arjun%"

So I would need to add parameters to my REST endpoint wherein i can fetch teh data based on name=%arjun% Is that really possible? 因此,我需要向我的REST端点添加参数,在其中我可以根据name =%arjun%提取数据。这真的有可能吗?

Thanks Arjun 感谢Arjun

I would recommend to user name=value and then create your sql with %%. 我建议用户name=value ,然后用%%创建您的sql。 You can put % into your GET call but it can cause bugs because % is special character which is used to encode other special characters. 您可以将%放入GET调用中,但会引起错误,因为%是特殊字符,用于编码其他特殊字符。

But if you really want to go with name=%value% then you can put %25 instead of %. 但是,如果您真的想使用name=%value%则可以使用%25代替%。 So something like this name=%25value%25 所以像这个name=%25value%25

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM