Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,367,394
Community Members
 
Community Events
168
Community Groups

Adding an external link to a feature via REST

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
[{
"op": "add",
"path": "/links/{{linksCount}}",
"value": { "path": {{pathURL}} , "name": {{linkName}}
}]

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"
}]

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"}
}]

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

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

OP = Add

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events