You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为API提供的Curl GET命令添加过滤(filter)参数?

Adding Filter Parameters to Your Curl Command

Hey there! Let's get that filter parameter working in your curl command—it's actually pretty straightforward once you handle the shell's quote escaping correctly.

Here's the Modified Command

Since you already know the filter works in Postman (?filter=userName co "random.user"), you just need to append that query string to the URL in your curl command. The key thing to watch out for is the double quotes around "random.user"—in a shell environment, these need to be escaped so the command doesn't break.

Here's the updated curl command:

curl -k -X GET -H "Authorization: Bearer $AccessToken" "https://xx/admin/v1/Users?filter=userName co \"random.user\"" -o search_results.json

Why This Works

  • We're keeping the URL wrapped in double quotes so the shell correctly expands the $AccessToken variable (if we used single quotes here, the variable wouldn't be replaced with your actual token).
  • The \" escapes the inner double quotes around "random.user", telling the shell that these quotes are part of the URL query string, not the end of the URL's quoted string.

Alternative: URL-Encoded Spaces (Optional)

If you prefer, you can replace the spaces in the filter with %20 (the URL-encoded version of a space) instead of relying on the shell to handle spaces in the quoted URL. This is also valid:

curl -k -X GET -H "Authorization: Bearer $AccessToken" "https://xx/admin/v1/Users?filter=userName%20co%20\"random.user\"" -o search_results.json

Either version should work exactly like your Postman request, returning the filtered user data.

内容的提问来源于stack exchange,提问作者Rohit Prasad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 22:27:39