Hi @Karishma Trehan,
I would recommend you to use Rest api to get the data for share link. Please refer to following api
_api/web/Lists(@a1)/GetItemById(@a2)/GetSharingInformation
Refer to the article for more details
https://cann0nf0dder.wordpress.com/2018/04/04/externally-sharing-getsharinginformation-rest-api/
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.