Stream: troubleshooting

Topic: βœ” Errors adding global role using API


view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 18:00):

hello all .. i'm trying to add a global role to our dataverse installation, and not getting very far. I've tried these formats for the api command:

curl http://localhost:8080/api/admin/roles -X POST -H 'Content-type:application/json' --upload-file roles.json

and

curl -H X-Dataverse-key:<my api token> -X POST "http://localhost:8080/api/admin/roles" --upload-file roles.json

and neither works .. for the first one it just returns nothing, and the second one returns "415 upsupported media type"

I used the format for the roles.json file that is in the docs

any thoughts?

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 18:19):

I also tried:
curl -H X-Dataverse-key:<my api token> -X POST http://localhost:8080/api/admin/roles -H 'Content-type:application/json' --upload-file roles.json

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 18:20):

and using env variables for server, token and export ID (and using the command directly from the docs)

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 18:20):

curl -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/admin/roles" --upload-file roles.json

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:02):

Hmm, I'm looking at this: Unify and de-duplicate role creation information. #9646

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:03):

Does your JSON look something like this?

{
  "alias": "sys1",
  "name": β€œRestricted System Role”,
  "description": β€œA person who may only add datasets.”,
  "permissions": [
    "AddDataset"
  ]
}

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:03):

From https://guides.dataverse.org/en/6.0/api/native-api.html#json-representation-of-a-role

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:03):

yes here it is:
{
"alias": "dsRsrchContrib",
"name": β€œResearch Contributor”,
"description": β€œLab manager, research data manager, graduate assistant.”,
"permissions": [
"ViewUnpublishedDataset",
"DownloadFile",
"EditDataset"
]
}

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:04):

Basically, I'm trying to say the docs were clean up recently so if you aren't looking at 5.14 or 6.0 docs you should. :grinning:

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:04):

although it is indented

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:04):

yeah, that looks right

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:04):

oh i'm looking at "latest"

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:04):

https://guides.dataverse.org/en/latest/api/native-api.html#create-global-role

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:05):

yeah, and latest is 6.0 right now, of course: https://guides.dataverse.org/en/6.0/api/native-api.html#create-global-role

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:05):

That curl command matches the second one you posted.

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:05):

should work!

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:05):

anything in server.log?

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:07):

hmmm .. i see this: "[Payara 6.2023.8] [SEVERE] [] [] [tid: _ThreadID=71 _ThreadName=http-thread-pool::http-listener-1(2)] [timeMillis: 1701457596607] [levelValue: 1000] [[
jakarta.ws.rs.ProcessingException: Error deserializing object from entity stream."

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:08):

and "Internal error: Unexpected char 8,220 at (line no=3, column no=11, offset=43)" .. must have something wrong in my json?

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:08):

oh ho!

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:08):

I see some not so smart quotes

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:09):

yes, that must be it! haha .. didn't even notice that .. will fix and try again (sorry should have looked in the payara log)

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:10):

well, we should probably return a better error

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:10):

please feel free to open an issue about this

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:10):

yep it worked .. omg i feel stupid

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:10):

you could link back to this thread

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:10):

glad it worked!

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:11):

thank you so much! next time i will check the log first!

view this post on Zulip Philip Durbin πŸš€ (Dec 01 2023 at 19:14):

No worries. I don't mind easy problems on a Friday afternoon. :stuck_out_tongue_wink:

view this post on Zulip Deirdre Kirmis (Dec 01 2023 at 19:14):

:big_smile:

view this post on Zulip Notification Bot (Dec 04 2023 at 07:00):

Oliver Bertuch has marked this topic as resolved.


Last updated: Oct 30 2025 at 06:21 UTC