HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In

Creating a Document Set in Layar

Now that we know how to upload documents, we can now make a set using the /layar/savedList endpoint.

Pre-Reqs

Make sure you have already followed the instructions for importing dependencies and authentication from the Getting Started Guide. You can use your token variable to authenticate your requests.

👍

Check Your Imported Modules

Make sure you have imported the requests and json module before proceeding with this guide.

🚧

Check Your Header

Sets can be made in both Curate and Layar. In order to determine where the set is created you will need to fill out X-Vyasa-Client in your header, with either layar or curate.

Creating Your Request Body

First, we need to create the set before we can upload documents to it. As with all API calls, we will need to fill out the body variable.

body = {
    'name' : 'NAME OF SET'   
       }

Create the Set

With body we can use request.post to create the set. We will also use json.get in order to create a variable for the set ID.

createSetUri = f'{envurl}/layar/savedList'

Response = Requests.post(createSetUri,
                        headers = header,
                        json = body)
setId = Response.json().get('id') #This adds the setId to a variable which we can use later
pprint(response) #Optional

Add Documents to a Set

We should already have a documentId variable from the previous section, we can utilize multiple IDs to add as many documents as we want to the set. As with previous API calls, we need to make the body that will be used in the request.

body = {
     'id' : [
           documentId1,
           documentId2
            ]
       }       

Request to Add Documents to a Set

Now we can use the setId and request.put to add the documents to the set.

addDocToSetUri = f'{envurl}/layar/savedList/{setId}/add'

Response = Request.put(addDocToSetUri,
                        headers = header,
                        json = body)

pprint(response) #Optional

As with all responses, a value of 200 means that it was successful. You can always double check in the Layar UI to see if your set is visible there.