HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In
Guides

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

Before a document search can be done the API requests must be authenticated. Make sure you have already followed the instructions for importing dependencies and authentication from the Getting Started Guide.

👍

Check Your Imported Modules

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

The following header can be used in your request.

header = {'Accept': 'application/json',
          'Content-Type': 'application/json',
          'Authorization': f"Bearer {token}",
          'X-Vyasa-Client': 'layar',
          'X-Vyasa-Data-Providers' : 'sandbox.certara.ai',
	  'X-Vyasa-Data-Fabric' : 'YOUR_FABRIC_ID'
  	 }

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.