Python中Workfront API多值场景下'in'/'notin'修饰符的正确用法
Problem Description
I'm using the python-workfront API to search for existing issues. Here's a simple working search example:
issues = session.search(api.Issue,name=nameSearch, name_Mod='contains',status='INP',status_Mod='notin')
However, when I try to add multiple values for the notin modifier, the search results only match the name condition, and the status filter seems to be ignored:
issues = session.search(api.Issue,name=nameSearch, name_Mod='contains',status=['INP','NEW'],status_Mod='notin')
What's the correct syntax to use the in or notin modifiers with multiple values?
Solution
I’ve run into this exact issue before with the python-workfront library. The key thing to note is that the API expects comma-separated strings for multi-value filters when using in or notin, not Python lists.
Here’s the corrected version of your code:
issues = session.search(api.Issue, name=nameSearch, name_Mod='contains', status='INP,NEW', status_Mod='notin')
Why This Works
The python-workfront library doesn’t automatically serialize Python lists into the comma-separated format that the underlying Workfront REST API requires for multi-value in/notin queries. When you pass a list, the library fails to parse it correctly, which results in the status filter being dropped entirely—hence why only your name condition was being applied.
For the in modifier, the syntax is identical:
# Get issues where status is either INP or NEW issues = session.search(api.Issue, status='INP,NEW', status_Mod='in')
内容的提问来源于stack exchange,提问作者Gregory Lancaster

