Impossible to make the HTTP call to star a dashboard

Hi,
I’m trying to make a POST on the Grafana API but I always got this error:

{ [Error: failed [500] {"message":"Failed to star dashboard"}]
   response:
    { statusCode: 500,
      content: '{"message":"Failed to star dashboard"}',
      headers:
       { 'content-type': 'application/json',
         date: 'Mon, 27 Mar 2017 12:52:23 GMT',
         'content-length': '38',
         connection: 'close' },
      data: { message: 'Failed to star dashboard' } } }

And in the Grafana logs I have:

lvl=eror msg="Failed to star dashboard" logger=context userId=0 orgId=1 uname= error="Command missing required fields"

That’s my call (idDash is set I have tested it):

HTTP.call("POST", GRAFANA_URL_API + 'user/stars/dashboard/' + idDash, {
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
                'Authorization': APIKEY_ADMIN,
            },
        },
        function(error, result) {
            if (!error) {
              console.log(result);
              idDash3 = idDash
              resolve(idDash3);
            } else {
                console.error("fail star dashboard");
                console.error(error);
                //throw error;
            }
        });

I even tried with empty data :

HTTP.call("POST", GRAFANA_URL_API + 'user/stars/dashboard/' + idDash, {
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
                'Authorization': APIKEY_ADMIN,
            },
            data: {
            }
        },
        function(error, result) {
            if (!error) {
              console.log(result);
              idDash3 = idDash
              resolve(idDash3);
            } else {
                console.error("fail star dashboard");
                console.error(error);
                //throw error;
            }
        });

What is missing ? Why it doesn’t work ?

You cannot star a dashboard using an API key currently as API keys are not assoicated with a user but an organization. So you need to use basic auth with username/password instead.

If this is related to changing home dashboard, you do not need to star a dashboard to set it to your org or user profile home dashboard. The starring is just used to limit the selection options in the dropdown in the profile/Org preferences UI.

But yesterday you told me that I needed to star it then to change the user preference with the api but I’ll try with basic auth so

Yes, I know. I forgot to say that starring it is not required, it is just for the dashboard to be selectable from the UI on the preferences pages.

Ok so I can skip this step I only need to:

GET my dashboard to pick the id
PUT the dashboard as home dashboard in preferences right ?

Yes, you can use the API key to change organization preferenses, but you will have the same error as above if you try to change user preferences. To change user preferences you need to use basic auth with a user credentials.

Ok I got it now, thank you for the help

Hi @torkel - How can we make the user preference change using http API when auth proxy is enabled? Do we have admin API for this?