MS Sharepoint REST API

nickas123 21 Reputation points
2021-09-16T13:07:56.317+00:00

Hello,

I would like to ask if possible to create or use existing REST API in Sharepoint in order to retrieve existing files in SharePoint and in the meantime to create new columns for posting retrieved content data of files?

For example,

Basically we have such columns:

Name Date Status

In the new case using existing REST API:

Name Date Status Id Worker_Name Licence.

I have tried to use this but not helped: http://mysite.sharepoint.com/<site_name>/_api/web/getfilebyserverrelativeurl('<url>)/$value?binaryStringResponseBody=true

Microsoft 365 and Office | SharePoint | Development
{count} votes

4 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2021-09-17T07:44:08.33+00:00

    Hi @nickas123 ,
    We need to get the file content by rest api like following code first
    133042-sample.txt
    Then we can read the file line by line. So we need to confirm is each line contains one column name and column type,and the index of them for us to retrieve and traverse and split them out.
    We can complete this step by javascript.
    Finally we can use rest api to create new columns with column names and types retrieved by js refer to following link
    https://www.codesharepoint.com/rest-api/create-list-column-in-sharepoint-using-rest-api


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.

    0 comments No comments

  2. nickas123 21 Reputation points
    2021-09-17T07:49:09.3+00:00

    Do I need to use both code parts: from yours .txt file and link below? And where to run these code parts? Are these code parts should be run in server or local or where?
    Also where to provide my sharepoint link for files content reading in these code part or just in first code block?


  3. nickas123 21 Reputation points
    2021-09-17T11:19:14.137+00:00

    133152-s-snip.png

    In that can't find media and content script editor.


  4. nickas123 21 Reputation points
    2021-09-17T12:39:15.557+00:00

    Hello, so seems something wrong. I can't pasted code here.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.