I want to use WsQueryOptions in a request to “Cards” > “readmany” in REST API V3.
I am trying to use WsQueryOptions, but it does not work as expected.
Can you tell me how to specify the “filterStr” parameter?
↓This returned the expected result.
url = '...services/rest/v3/classes/Account/cards'
params = {
"limit": 2,
"attrs": ['Description', 'Code'],
# "filterStr": "Description=something"
}
res = cmdbuild.request_get(url=url, params=params)
print(res.text)
```
However, ↓this was not filtered out by filterStr.
```
url = '...services/rest/v3/classes/Account/cards'.
params = {
"limit": 2,
"attrs": ['Description', 'Code'],
"filterStr": "Description=something"
}
res = cmdbuild.request_get(url=url, params=params)
print(res.text)
```
I tried several patterns, but could not find a valid expression.
It would be appreciated if you could tell me how to make a valid request.
Thank you.
Mizuki
Hi Mizuki,
I struggled with this for several days and tried everything I could think of. In the end I solved it using query language and urlencode. Weird, but the standard key=value syntax you are using just didn’t work for me no matter what I did.
This is the query structure that worked for me in the end (just an example based on your code - won’t be 100% right but you get the idea):
{“attribute”:“simple”,“operator”:“equal”,attribute:“Description”,“value”:“something”}
Then urlencode it so that you get something like this (truncated as it’s a long string):
%7B%22attribute%22%3A%20%7B%22simple%22%3A%20%7B%22operator%22… etc
Then use that as your filter argument.
One thing to note, I did not use filterStr as that just wouldn’t work. Using filter as the keyword did.
Good luck.
I used the “simple filter” syntax described on page 49 of this document, and finally it worked!
https:// usermanual.wiki/Document/CMDBuildTechnicalManualENGV240.1276356727/html
↑I can’t include URL in my post, so please eliminate space follows “https://” .
Trying to run tests in SOAPUI on the REST endpoints using a filter defined in openMAINT (‘class filter’)as a parameter but cannot get the filter to work no matter the format of the string value. Am I incorrect in my thinking here? I understand you can create the filter in a JSON using the simple syntax mentioned in this thread but has anyone been able to use a ‘class filter’ in a request or are theses only useful in the openMAINT UI?
I was able to run requests with complex search filters, I believe I was incorrect in thinking I could use the openMAINT class filters. The format and syntax for the filter is:
This is just an example, adjust to your needs by changing the ‘operator’ and ‘attribute’ values. Be sure to insert your search parameters in place of ‘{your-attribute}’ and ‘{your-value}’