Adding an external link to a feature via REST

Mark Northcott
Contributor
August 21, 2022

Hello All,

I'm creating a web app that will allow additional feature information to be saved via page to a DB and need to add a link to the feature dynamically. The only way I see to do this is via REST but I'm unsure if this can be done via REST as the info is stored in the External Reference table, not the Feature table, and needs its own unique ID

A GET gets me the following
"links": [
{
"id": 62,
"name": "Test1",
"link": "https://xxxxxxxxxxxxx.azurewebsites.net"
}
],

Using the following as PATCH wont work ( I know the value is wrong, it needs to be like above but how would I get an ID? )

[
{
"value": "https://xxxxxxxxxxxxxx.azurewebsites.net",
"path": "/links",
"op": "replace",

}
]

Any thoughts on how to do this?

2 answers

1 accepted

1 vote
Answer accepted
Allan Maxwell
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 21, 2022
[{
"op": "add",
"path": "/links/{{linksCount}}",
"value": { "path": {{pathURL}} , "name": {{linkName}}
}]
Mark Northcott
Contributor
August 21, 2022

Thanks for your reply Allan.

You're moving me in the right direction but I still don't get the solution. I know this is wrong. Is the linkcount derived from somewher or do I hard code it?  

[{
"op": "add",
"path": "/links/{{linksCount}}",
"value": "path": "https://xxxxxxxxxxxxx.azurewebsites.net" , "name": "TEST3"
}]

Mark Northcott
Contributor
August 21, 2022

I finally found a way to do it, with a dash all that was needed to create the next link. also change from path to link works. Thanks Allan.

[{
"op": "add",
"path": "/links/-",
"value": {"name": "TEST4", "link": "https://xxxxxxxxxxxxx.azurewebsites.net"}
}]

Allan Maxwell
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 22, 2022

Cool ...didn't know about the dash.  I was passing in a count to append to end ...the dash is easier.

Like Mark Northcott likes this
0 votes
Mark Northcott
Contributor
August 21, 2022

So I get now that "path": "/links/0/name" is the way you modify a value such as name in the link and I have confirmed that the following does modify the name of the link, and the ExternalReference data

{
"op": "replace",
"path": "/links/0/name",
"value": "Test1A"
}

I also tried replacing replace with add but that just replaced.

 

Now I just need to find out how to add a new External Reference

Allan Maxwell
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 21, 2022

OP = Add

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events