Hello, I am getting this error ```{ "error" : {...
# gooddata-platform
g
Hello, I am getting this error
Copy code
{
  "error": {
    "component": "Apache::REST",
    "errorClass": "GDC::Exception::User",
    "message": "Exactly one key must be specified in hash structure",
    "parameters": [],
    "requestId": "XicuFLzWLbhUcb1M:tme2g0k7no3ejuiw"
  }
}
trying to access my gooddata resources…i have successfully authenticated but i can’t load the dashboard what do i do? thanks in advance
j
Hi Gideon. In general, this sort of response means that the API expects only one JSON key-value pair. For example:
Copy code
{
  "first": {
    "example": 1
  }
}
And NOT
Copy code
{
  "first": {
    "example": 1
  },
  "second": {
    "example": 2
  }
}
From the request ID, I can see you were trying to use the /identifier endpoint. The accepted structure for that is:
Copy code
{
  "identifierToUri": [
    "one",
    "two",
    "three",
    "etc"
  ]
}
g
@Jan Rehanek thanks for your response…i just integrated the dashboard component from
import { Dashboard } from "@gooddata/sdk-ui-dashboard";
so gooddata is the one making the api call
at this point i’m. not sure i am handing any api call outside authentication, so how do i resolve this
j
Could you share the code snippet with us? Ideally the whole component.
g
herte is all i’m doing
j
Could you copy-paste it as code instead? It is difficult to troubleshoot from a picture 🙂 Of course replace any sensitive data with placeholders.
g
const sdk = getFactory({ domain: window.location.hostname });
const dashboardID = idRef("");
const dashboardConfig = {
isEmbedded: true,
isReadOnly: true,
};
const dashboardPermissions = {
canInitData: true,
canCreateScheduledMail: false,
canListUsersInProject: false,
};
const [backend, setBackend] = useState(null);
useEffect(() => {
(async () => {
try {
if (!(await sdk.user.isLoggedIn())) {
await sdk.user.login("username", "password");
}
const bear = bearFactory().withAuthentication(
new ContextDeferredAuthProvider()
);
setBackend(bear);
} catch (err) {
console.error(err);
}
})();
}, []);
return (
<Dashboard
backend={backend}
workspace=""
dashboard={dashboardID}
config={dashboardConfig}
permissions={dashboardPermissions}
/>
);
@Jan Rehanek here are the packages used
import { getFactory } from "@gooddata/api-client-bear";
import bearFactory, {
ContextDeferredAuthProvider,
} from "@gooddata/sdk-backend-bear";
import { Dashboard } from "@gooddata/sdk-ui-dashboard";
import { idRef } from "@gooddata/sdk-model";
@Jan Rehanek was anything changed? Because it just suddenly started working
j
Nothing was changed 🤔
I will take a look at your code now.
Hello Gideon. I had a chat with one of our engineers. From what we can see, there’s nothing in the code you’ve sent that would cause the error you described. You could use the
FixedLoginAndPasswordAuthProvider
instead of
Copy code
if (!(await sdk.user.isLoggedIn())) {
    await sdk.user.login("username", "password");
}
const bear = bearFactory().withAuthentication(
    new ContextDeferredAuthProvider()
);
to handle the login, but that should be unrelated. Anyway, if it is working correctly now, the problem was probably somewhere we cannot see and was resolved independently.