cancel
Showing results for 
Search instead for 
Did you mean: 

Finding Existing Links to a File or Folder using API

Highlighted

Finding Existing Links to a File or Folder using API

Jump to solution

I can make a link for a file, using a full path and the links API.

But I cannot get the API to give me an existing link for such a file - I'd like to re-use links rather than make new ones every time, since we use a lot of permanent links for our system manuals.

 

In other words, if I want to use an existing link rather than make a new one, I can’t make it work. The GET option for the API always returns ALL links, regardless of whether I use the path option or not. It returns no error, but simply returns 2,000 links which obviously are not associated with that file.

I don't want to have to go through thousands of links returned by the API to see if the right one is among them (I'd have to get a full path for each link ID, and "spin my wheels" endlessly to check)

 

Here’s the API documentation: https://developers.egnyte.com/docs/read/Egnyte_Link_API_Documentation#List-Links

 

This implies that the “Path” parameter can be used to return links for just a file or folder. I am finding that I can use the “Post” version just fine to make a link (which also makes it look like the syntax of my path is correct, because it recognizes the path there, and returns a new link), but not the GET version.

 

  • Here’s my code: This first code does not work (returns all links ever made instead of file specific ones)

            targeturl = Domain_ID & "pubapi/v1/links"

            Set HTTPReq = CreateObject("MSXML2.XMLHTTP")

            HTTPReq.Open "Get", targeturl, False

            HTTPReq.SetRequestHeader "Authorization: ", "Bearer " & Auth_Code

            HTTPReq.SetRequestHeader "Content-Type", "application/json"

           

            HTTPReq.Send paramstr_get

            JSON_Response = HTTPReq.responseText

 

 

  • Here’s the second code: This works, and returns a new link

                targeturl = Domain_ID & "pubapi/v1/links"

                Set HTTPReq = CreateObject("MSXML2.XMLHTTP")

                HTTPReq.Open "Post", targeturl, False

                HTTPReq.SetRequestHeader "Authorization: ", "Bearer " & Auth_Code

                HTTPReq.SetRequestHeader "Content-Type", "application/json"

               

                HTTPReq.Send paramstr_post

                JSON_Response = HTTPReq.responseText

 

 

The “Path” parameter is assembled the same way in either case. Here’s an example of the strings used for the path

 

Paramstr_get = {"path":"/Shared/Jobs/SDSU/ARC Expansion/2019 NC Cx Reinhard/Deliverables/SDSU Arc Exp NC Cx on Box/2. Design/2.10 OPR-CFR/010000-00 Curr Facility Rqts/Rev 00 Program/Delv","accessibility":"anyone"}

 

Paramstr_post = {"path":"/Shared/Jobs/SDSU/ARC Expansion/2019 NC Cx Reinhard/Deliverables/SDSU Arc Exp NC Cx on Box/2. Design/2.10 OPR-CFR/010000-00 Curr Facility Rqts/Rev 00 Program/Delv","type":"folder","accessibility":"anyone","link_to_current":"true"}

 

 

Is there a way to get existing links for particular files or folders?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Highlighted

Re: Finding Existing Links to a File or Folder using API

Jump to solution

Got my reply from the Egnyte helpdesk, which works:

Raees Khan (Egnyte)

Apr 20, 7:49 AM PDT

Hi Reinhard,

Apologies for the delay.

The file/folder path needs to be sent as a query string to the URL. For example, in order to list links for '/Shared/Documens/myfile.txt', I would make the following GET request.

GET https://domain.egnyte.com/pubapi/v2/links?path=/Shared/Documents/myfile.txt

Thanks,
Raees

View solution in original post

0 Kudos
1 Reply
Highlighted

Re: Finding Existing Links to a File or Folder using API

Jump to solution

Got my reply from the Egnyte helpdesk, which works:

Raees Khan (Egnyte)

Apr 20, 7:49 AM PDT

Hi Reinhard,

Apologies for the delay.

The file/folder path needs to be sent as a query string to the URL. For example, in order to list links for '/Shared/Documens/myfile.txt', I would make the following GET request.

GET https://domain.egnyte.com/pubapi/v2/links?path=/Shared/Documents/myfile.txt

Thanks,
Raees

View solution in original post

0 Kudos
Users online (498)