Solved

API error - GDC::Exception::NotFound


Hello, please help me.  I tried to get all users in my project over API reguest.  I got error message. What does it mean?

 

 

icon

Best answer by Jan Rehanek 5 May 2022, 11:17

View original

44 replies

Thank you very much for summary.

Problem is that I get different response, than you show.

  1. First step

 

Response:

{
"variables": [
{
"prompt": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/6476",
"level": "project",
"related": "/gdc/projects/vqhnjvya515i05v3jawkf740y77j59xh",
"expression": "113",
"uri": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/variables/item/1",
"type": "scalar"
},
{
"uri": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/variables/item/10",
"type": "filter",
"prompt": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/14567",
"tree": {
"type": "true",
"position": {
"line": 1,
"column": 14
}
},
"level": "project",
"expression": "TRUE",
"related": "/gdc/projects/vqhnjvya515i05v3jawkf740y77j59xh"
},
{
"type": "scalar",
"uri": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/variables/item/2",
"prompt": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/6476",
"related": "/gdc/account/profile/86b784c72bb79d0fe11251f881d2574b",
"level": "user",
"expression": "113"
},
{
"uri": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/variables/item/6",
"type": "filter",
"prompt": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12887",
"tree": {
"type": "true",
"position": {
"column": 14,
"line": 1
}
},
"related": "/gdc/projects/vqhnjvya515i05v3jawkf740y77j59xh",
"level": "project",
"expression": "TRUE"
},
{
"type": "filter",
"uri": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/variables/item/7",
"prompt": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12887",
"related": "/gdc/account/profile/86b784c72bb79d0fe11251f881d2574b",
"tree": {
"content": [
{
"type": "attribute object",
"position": {
"column": 14,
"line": 1
},
"value": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524"
},
{
"type": "list",
"position": {
"line": 1,
"column": 71
},
"content": [
{
"position": {
"column": 71,
"line": 1
},
"type": "attributeElement object",
"value": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524/elements?id=68269"
}
]
}
],
"position": {
"column": 67,
"line": 1
},
"type": "in"
},
"level": "user",
"expression": "[/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524] IN ([/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524/elements?id=68269])"
},
{
"level": "user",
"tree": {
"content": [
{
"value": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524",
"position": {
"line": 1,
"column": 14
},
"type": "attribute object"
},
{
"content": [
{
"position": {
"column": 71,
"line": 1
},
"type": "attributeElement object",
"value": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524/elements?id=68312"
}
],
"position": {
"column": 71,
"line": 1
},
"type": "list"
}
],
"type": "in",
"position": {
"column": 67,
"line": 1
}
},
"related": "/gdc/account/profile/78a9bb9b043434ef87d4ab5d472ac839",
"expression": "[/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524] IN ([/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524/elements?id=68312])",
"prompt": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12887",
"uri": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/variables/item/8",
"type": "filter"
},
{
"uri": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/variables/item/9",
"type": "filter",
"prompt": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/14566",
"tree": {
"position": {
"column": 14,
"line": 1
},
"type": "true"
},
"related": "/gdc/projects/vqhnjvya515i05v3jawkf740y77j59xh",
"level": "project",
"expression": "TRUE"
}
]
}

 

2) Second step. Filter over object. I used this object 

    /gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524  Is it right ?

 

  

   I got this answer:

 

 

I don't know where is problem.

 

 

 

 

Userlevel 3

I corrected my previous post to reflect the filtering on the variable object - there was an inaccuracy there.

 In order to filter by user, please compose the request like this, where the context value reflects the ID of the profile you are trying to filter for:

{
"variablesSearch": {
"variables": [
],
"context": [
"/gdc/account/profile/d61c6cc59f2c996211f3dc3f1aa9c5be"
],
"searchOptions": {
"offset": 0,
"limit": 500
}
}
}

 

Hello, I did it.

 

Response:

{
"variables": [
{
"prompt": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/6476",
"expression": "113",
"level": "user",
"type": "scalar",
"related": "/gdc/account/profile/86b784c72bb79d0fe11251f881d2574b",
"uri": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/variables/item/2"
},
{
"uri": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/variables/item/7",
"prompt": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12887",
"expression": "[/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524] IN ([/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524/elements?id=68269])",
"level": "user",
"type": "filter",
"tree": {
"position": {
"column": 67,
"line": 1
},
"content": [
{
"position": {
"column": 14,
"line": 1
},
"type": "attribute object",
"value": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524"
},
{
"type": "list",
"position": {
"line": 1,
"column": 71
},
"content": [
{
"position": {
"line": 1,
"column": 71
},
"type": "attributeElement object",
"value": "/gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524/elements?id=68269"
}
]
}
],
"type": "in"
},
"related": "/gdc/account/profile/86b784c72bb79d0fe11251f881d2574b"
}
]
}

What next ?

I think, that I got the same value object “ /gdc/md/vqhnjvya515i05v3jawkf740y77j59xh/obj/12524”

Please, can you get answer where is problem ?

Userlevel 3

Hello,

If you receive a response of the type “filter”, there are extra steps that need to be taken. We start with this reply from the /variables/search endpoint: 

{
    "variables": [
        {
            "expression": "[/gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/446] IN ([/gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/446/elements?id=1126])",
            "type": "filter",
            "uri": "/gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/variables/item/13",
            "level": "user",
            "tree": ...,
            "related": "/gdc/account/profile/d61c6cc59f2c996211f3dc3f1aa9c5be",
            "prompt": "/gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/510"
        }
        ...
    ]
}

To retrieve the value of the variable which is of type filter, first you must retrieve the attributeDisplayForm ID. Use the first part of the "expression" value and submit a GET request. In my example, this will be to the following address:  https://<domain>/gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/446

From there, you should retrieve the object ID from "attribute"/"content"/"displayForms"[index]/"links"/"elements":

{
    "attribute": {
        "content": {
            "displayForms": [
                {
                    "links": {
                        "elements": "/gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/447/elements"
                    },
            ...
    }
}

The ID of the attributeDisplayForm in my example is 447.

Then we take second link from the "expression" value and adjust it from /gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/446/elements?id=1126 to /gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/447/elements?id=1126 and submit a GET request to this address. Be sure to adjust the links so that they fit your unique workspace identifiers and object IDs. If the steps were performed correctly, you will receive a reply of this type and be able to retrieve the variable value from "attributeElements"/"elements"[index]/"title":

{
    "attributeElements": {
        "elements": [
            {
                "title": "10065",
                "uri": "/gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/446/elements?id=1126"
            }
        ],
        "elementsMeta": {
            "order": "asc",
            "prompt": "",
            "filter": "",
            "attribute": "/gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/446",
            "mode": "includeuris",
            "offset": "0",
            "records": "1",
            "count": 1,
            "attributeDisplayForm": "/gdc/md/icbkspun9y7r4rz361y7oblj8o5vz51i/obj/447"
        },
        "paging": {
            "next": null,
            "count": 1,
            "total": "1",
            "offset": "0"
        }
    }
}

The value is was looking for was the identifier 10065.

In order to do this in large numbers for a large number of attributes and variables, you will need some sort of programmatic solution on your end. It will need to be able to parse the JSON files, retrieve the object IDs, and construct appropriate links to send the GET requests to.

Hope this helps,

Hello, now it is OK.  Thank you very much.

 

Now, I try create variable for user.

I got this error response.  Please help me.

 

 

 

Please, can you get answer where is problem ?

Hello, I need continue , please can you send me answer about my problem ?

 

 

I also try to get information about usergroup. I got this error response.

 

 

Documentation:

 

Userlevel 3

Hello,

Your problem there with the “"'\"' expected, at character offset” error is a trailing comma in the variable object definition.

This is not really related to GoodData as a platform, but concerns JSON syntax. For more information on JSON, I would recommend reading through https://www.json.org/json-en.html and enforcing some sort of syntax validation before sending an API call.

 

Edit: For the projects groups, the API is defined under https://help.gooddata.com/doc/enterprise/en/expand-your-gooddata-platform/api-reference#tag/user-groups. Important part is this: 

query Parameters
user

string

Optional user UID filter.

project

string

Project filter. Mandatory in most cases.

 

Query parameter is expected - ?project=<project_id>

Hello , now call API project user groups is without problems.  Thank you.

 

Your problem there with the “"'\"' expected, at character offset” error is a trailing comma in the variable object definition.

This is not really related to GoodData as a platform, but concerns JSON syntax. For more information on JSON, I would recommend reading through https://www.json.org/json-en.html and enforcing some sort of syntax validation before sending an API call.

 

I change JSON syntax. I got this error answer.  Please help me. Thank you very much.

 

 

 

 

 

 

 

 

 

 

 

Second problem is how add user into user group. I did not find API for this function. Please help me too. Thank you very much.

Hello, I would like to finish this task , please can you send me answer about my two problems ?

Userlevel 3

 

  1. I believe you the error is clear and you need to use “variables” and not “variable” 

 

 

  1. To add a user to a group you can follow the following template for the api: 

 

 

POST:
<Domain>/gdc/userGroups/group_id/modifyMembers

Use parameters: group_id
Content-Type: application/json

Body:

{
"modifyMembers": {
"operation": "SET",
"items": [
"/gdc/userGroups/{group_id}",
"/gdc/account/profile/{profile_id}",
"/gdc/userGroups/{group_id}",
"/gdc/account/profile/{profile_id}"
]
}
}

Hello, I change words “variable” into “variables”. I got the same error.

 

 

The API for add user into usergroup don't  send response.  

 

 

Please can you send me answer about my two problems TODAY?

 

 

Userlevel 3

Hello,

Regarding the userGroups:

POST to <domain>.com/gdc/userGroups/<group_id/modifyMembers

SET deletes and adds users so that the group's membership is exactly as listed in the "items" array:

{
    "modifyMembers": {
        "operation": "SET",
        "items": [
            "/gdc/account/profile/a312d87ff81a2975306688000cfb915a"
        ]
    }
}

ADD adds users to the group using the user IDs from the "items" array:

{
    "modifyMembers": {
        "operation": "ADD",
        "items": [
            "/gdc/account/profile/a312d87ff81a2975306688000cfb915a"
        ]
    }
}

REMOVE removes users from the group using the user IDs from the "items" array:

{
    "modifyMembers": {
        "operation": "REMOVE",
        "items": [
            "/gdc/account/profile/a312d87ff81a2975306688000cfb915a"
        ]
    }
}


Regarding your variable error:

If you are using the "variable" key, the value cannot be an array, but has to be an object instead. Use this:

{
"variable": {
"related": "..."
}
}

NOT

{
"variable": [
{
"related": "..."
}
]
}

 

Hello, 

I changed according to the instructions.

1)

 

IF I change “variable” to “variables”

 

  1. ADD adds users to the group using the user IDs from the "items" array:

 

 

The API for add user into usergroup don't  send response.  

 

Please can you send me answer about my two problems TODAY?

 

 

 

Please can you send me answer about my two problems ? I would like to finish this task.

Userlevel 2

Dear @plaube.

I am afraid this thread went beyond what community around GoodData products can provide. It seems it is rather for an implementation package from GoodData.

Best regards.

Martin

Reply