I have a self URL like https://your-domain.atlassian.net/rest/api/3/project/MKY/role/10002 from a previous api call like get project roles for a project.
In this case I would probably remove the site URL from the path and add the remaining part of the URL to the requestJira method using route as well.
What do you think?
The assumeTrustedRoute difference is related to how the request parameter are treated, it is still expecting just API endpoint without the site URL.
Just to leave an example here, here is how to use it:
import api, { assumeTrustedRoute } from "@forge/api";
...
const res = await api
.asUser()
.requestJira(assumeTrustedRoute("/rest/api/3/project/10000/role/10003"));
Hello @ccurti, thank you for your support! If also assumeTrustedRoute expects an URL without site, then I cannot use the self URL directly, need to create substring and then I can also use regular requestJira() with route. So, this is my code now.
const fetchSelf = async (self) => {
let position = self.search("/rest/api/");
let subself = self.substr(position);
const res = await api
.asUser()
.requestJira(route`${subself}`);
const data = await res.json();
return data;
};
Strange concept that requestJira() does not accept a self URL. Maybe something to think about at Atlassian.