Registry Aspect API Usage #3338
-
Hi, I I'm currently developing with MAGDA and having an issue using the Registry Aspect API on my instance. What I am trying to do is modify an Aspect by ID, specifically the project-open-data dataset and distribution references but I receive an "Unauthorized" error message with a 401 error code. The MAGDA instance was set up using the Magda-config repository which has a MAGDA helm chart version of '0.0.59'. I receive this error when preforming a PUT and JSON PATCH, here is an example of my PUT request where I include all necessary headers. The JWT was created using the acs-cmd tool. var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var url = "http://dn.datacube.online/api/v0/registry/aspects/project-open-data-dataset";
var xhr = new XMLHttpRequest();
xhr.open("PUT", url);
xhr.setRequestHeader("X-Magda-Session", "<JWT>");
xhr.setRequestHeader("X-Magda-API-Key-Id", "<API-KEY-ID>");
xhr.setRequestHeader("X-Magda-Tenant-Id", 0);
xhr.setRequestHeader("X-Magda-API-Key", "<API-KEY>");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.status);
console.log(xhr.responseText);
}};
var data = `{
"$schema": "http://json-schema.org/schema#",
"title": "Aspect capturing a complete representation of a dataset according to Project Open Data (data.json).",
"type": "object",
"allOf": [
{
"$ref": "https://raw.githubusercontent.com/BrandonFeldhaus/project-open-data-dashboard/main/schema/non-federal-v1.1/dataset-non-federal.json"
}
]
}`;
xhr.send(data); My initial thinking is this error could be related to the limited opa policies and auth policies in place for this specific version of MAGDA and that I should migrate to a newer version of the release but not to sure the best way to go about this using the Magda-config repository. Any recommendations or help greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @BrandonFeldhaus, |
Beta Was this translation helpful? Give feedback.
Hi @BrandonFeldhaus,
Noticed you also attached the
X-Magda-Session
(JWT token) header.In fact, if we use the API key already, we don't need the
X-Magda-Session
header.The API key option is actually a better option if we talk to Magda externally (outside the cluster) and
X-Magda-Session
is mainly used internally (inside the cluster behind the Magda gateway module).Could you please drop the X-Magda-Session header and try again?
By the way, not sure whether you come across our Magda tutorial repo. It might cover a similar topic.
https://github.com/magda-io/magda-brown-bag