Hi I am looking for some support on adding a user ...
# gooddata-cloud
g
Hi I am looking for some support on adding a user group data filter. I have done this before using postman so I copied a previous request, changed the workspace#, usergroupid, and the value of the filter. I get a 'bad request error, see attachment. The label mentioned does exist in the workspace.
k
The error in your screenshot is: > "Some of given referenced 'labels' entities do not exist. Not existing IDs: [Identifier(Site)/Workspace(...)]" This is a 400 Bad Request caused by an invalid label ID in your MAQL expression — specifically, the label identifier
Site
(or however it's referenced in your filter) does not exist in the target workspace. Here are the most likely causes and fixes: 1. Wrong Label ID in the MAQL Expression When you copied the previous request and changed the workspace, the label ID used in the
maql
field may not exist in the new workspace, or the ID itself is incorrect. Label IDs are case-sensitive. [Community Slack] Double-check the exact label ID in the new workspace. For example, if your MAQL looks like:
Copy code
{label/Site} = "some_value"
Make sure
Site
matches the exact label ID (including capitalization) as it exists in the target workspace's logical data model. 2. Correct JSON Structure for a User Group Filter Also verify your JSON body uses
userGroup
(not
user
) for both the relationship key and the type value. A common mistake is setting the type correctly but using the wrong relationship key. [Community Slack] The correct structure for a user group filter via the Entity API is:
Copy code
{
  "data": {
    "type": "userDataFilter",
    "id": "<data-filter-id>",
    "attributes": {
      "maql": "{label/your_label_id} = \"your_value\"",
      "title": "<data-filter-name>"
    },
    "relationships": {
      "userGroup": {
        "data": {
          "id": "<user-group-id>",
          "type": "userGroup"
        }
      }
    }
  }
}
Note that both the relationship key (
userGroup
) and the type value (
"userGroup"
) must be set correctly. [Set Up User Data Filters] Steps to Resolve 1. Verify the label ID in your MAQL expression exists in the new workspace (check the LDM of that workspace). 2. Ensure the label ID is exactly correct, including case sensitivity. 3. Confirm the
userGroup
relationship key and type are both set to
userGroup
. 👍 0 button 👎 0 button ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups. 👀 Our Support team monitors all messages and will jump in if needed.
g
All this looks correct. I am stuck and could use support team assistance.
👀 1
m
Hi Greg, we are looking into this, could you share with us the body you are sending in your request please? feel free to use dm
g
Thx. I just DM
m
Hi Greg, to look into this further we used impersonation with our technical user with Admin rights — the only actions taken were locating your workspace and searching the LDM for the "Site" and "site" attributes, no further actions were performed and no screenshots were taken. We found the label does exist in the workspace, however its internal ID is
site
(lowercase), not
Site
— and since the MAQL filter is case-sensitive, the API couldn't find it. Please update your request to use
{label/site}
instead of
{label/Site}
and give it a try!
g
Hi Mauricio, I change to 'site' lower case and it ran with a '201 created' message. Seems good however I ran a test with a user that is in that usergroup that this filter was seton and the data is not filtered. can you tell if it looks correct?
m
Hi Greg, let me check our logs, in the meantime please, provide the user_id by dm.
HI, looking at the activity in the workspace in our logs, we can see the filter was set up correctly, however the analytics executions we're seeing were run under a different user account as the provided by dm. Could you confirm that when you tested, you logged in as the actual end user (not your admin account) and ran the report from their session? Additionally, could you verify once more that the test user is assigned to the user group
172bc3***
that the filter is linked to? If they're not a member of that group, the filter won't apply to them. Those two things are the most likely explanation for what you're seeing.
g
I did login to test as the actual end user and I verified that user is in the filtered usergroup. I'm not spotting the issue.
m
HI Greg, Thank you for your patience. After reviewing your setup, using impersonation, to check the LDM and some test in the Analytical Designer. I found the issue: the
userDataFilter
is using
{label/site}
, which points to a different attribute in your data model — one that only contains a single value and doesn't include the value you are filtering. The correct attribute to use is
v_site.site
, which belongs to the another dataset and does contain the expected site values. To fix this, please update the MAQL in your UDF definition: change this
{label/site}
to
{label/v_site.site}
, keeping the rest of the filter as-is. Give it a try and let us know if the data filter is applied correctly for the test user.
g
ok, makes sense. I changed to v_site,site and get a 409 conflict this filter id already exists in the DB. I know I could probably tweak the id name but that would leave the first filter in place too. I should delete the first filter or can you delete it? I don't have a postman code for deleting a udf.
m
Hi Greg, We confirmed via our logs that the 409 Conflict you received on May 16th was because the request used POST on an ID that already exists (
udf_****_148
). POST is for creating new entities — since a filter with that ID was already in the database, the API rejected it. That's expected behavior. You have two options to fix this — both work, pick whichever feels easier: Option 1 — <http:///api/v1/entities/workspaces/{workspaceId}/userDataFilters/{objectId}|PATCH> (recommended, one call): Update the existing filter in place. No need to delete anything, the userGroup relationship stays intact.
Copy code
PATCH /api/v1/entities/workspaces/{workspace_id}/userDataFilters/{userDataFilter_id}
Content-Type: application/vnd.gooddata.api+json

{
  "data": {
    "type": "userDataFilter",
    "id": "{userDataFilter_id}",
    "attributes": {
      "maql": "{label/v_site.site} = {your_filer_value}
    }
  }
}
Option 2 — <http:///api/v1/entities/workspaces/{workspaceId}/userDataFilters/{objectId}|DELETE> + <http:///api/v1/entities/workspaces/{workspaceId}/userDataFilters/{objectId}|POST> (two calls): Delete the existing filter first, then recreate it with the correct MAQL. If you go this route, make sure to include the
userGroup
relationship in the POST body, otherwise the filter won't be linked to the group.
Copy code
DELETE /api/v1/entities/workspaces/{workspace_id}/userDataFilters/{userDataFilter_id}
Let us know if you run into any issues!
g
Mauricio, thank you. I was able to accomplish option 2 delete + post. My testing shows the data filter is working. Thank you!