The API Script panel in dqMan allows users to create, edit, and execute API requests in a script format. It provides a structured way to define API calls, making it easier to automate and test interactions with the Veeva Vault API.
Script-Based API Requests
Users can manually write or generate API scripts to interact with Veeva Vault.
Scripts follow a structured format, typically including the HTTP method, headers, and API URL.
Script Structure
HTTP Method: GET (to retrieve data)
Headers:
Generating API Scripts
Users can right-click an API request from the API Collection and select "Generate Script" to automatically create an API script based on the selected request.
Executing API Scripts
Users can run the script using the Run Script button in the toolbar.
The results of the API request will be displayed in the Response Panel.
Flexibility & Customization
Users can modify scripts to include parameters, variables, and different request types (GET, POST, PUT, DELETE).
This makes it easier to automate repetitive API testing tasks.
Here’s an example of a POST request to create a new document in Veeva Vault using an API script in dqMan:
POST → Specifies the HTTP method to create a new document.
Headers:
"Authorization: {{sessionId}}" → Uses a session token for authentication.
Click "Run Script" in dqMan to execute the request.
The response will confirm whether the document was successfully created.
This script updates an existing document’s name and lifecycle in Veeva Vault.
Explanation:
PUT → Used for updating an existing document.
Headers:
"Authorization: {{sessionId}}" → Uses a session token for authentication.
This script deletes an existing document from Veeva Vault.
Explanation:
DELETE → Used to remove a document from the Vault.
Headers:
"Authorization: {{sessionId}}" → Ensures authentication.
This script fetches details of a specific document from Veeva Vault.
Explanation:
GET → Used to retrieve document details.
Headers:
"Authorization: {{sessionId}}" → Ensures authentication.
This script retrieves a list of all documents stored in the Vault.
Explanation:
GET → Used to retrieve multiple documents.
Headers:
"Authorization: {{sessionId}}" → Ensures authentication.
"Authorization: {{sessionId}}" → Uses a session variable for authentication."Accept: application/json" → Specifies that the response should be in JSON format.
API Endpoint:
The script calls https://{{vaultDNS}}/api/{{version}}/delegation/vaults to retrieve delegated access information.
Redirect results to file: If the API call result is a file, the full path to the file can be specified in the API script as the last line using >PATH
"Content-Type: application/json" → Defines that the request body is in JSON format.--data Section:
This JSON payload contains document details:
"name__v": The document name (e.g., "Test Document").
"type__v": The document type (e.g., "general__c").
"lifecycle__v": The document’s lifecycle state (e.g., "Draft").
API Endpoint:
The request is sent to https://{{vaultDNS}}/api/{{version}}/objects/documents, where {{vaultDNS}} and {{version}} are placeholders for the Vault domain and API version.
"Content-Type: application/json" → Defines the request body format.--data Section:
Updates the document’s name and changes its lifecycle to "In Review".
API Endpoint:
https://{{vaultDNS}}/api/{{version}}/objects/documents/0000000000004ED
Replace 0000000000004ED with the actual document ID.
https://{{vaultDNS}}/api/{{version}}/objects/documents/0000000000004ED
Replace 0000000000004ED with the actual document ID.
"Accept: application/json" → Requests the response in JSON format.API Endpoint:
https://{{vaultDNS}}/api/{{version}}/objects/documents/0000000000004ED
Replace 0000000000004ED with the actual document ID.
"Accept: application/json" → Requests the response in JSON format.API Endpoint:
https://{{vaultDNS}}/api/{{version}}/objects/documents
Retrieves a list of documents.
GET // Download Daily API Usage
--header "Authorization:{{sessionId}}"
--header "Accept:application/json"
--data-urlencode date=2025-02-12
https://{{vaultDNS}}/api/{{version}}/logs/api_usage
>C:\Users\admin\pathPOST // Create a new document
--header "Authorization: {{sessionId}}"
--header "Content-Type: application/json"
--data "{
\"name__v\": \"Test Document\",
\"type__v\": \"general__c\",
\"lifecycle__v\": \"Draft\"
}"
https://{{vaultDNS}}/api/{{version}}/objects/documentsPUT // Update an existing document
--header "Authorization: {{sessionId}}"
--header "Content-Type: application/json"
--data "{
\"name__v\": \"Updated Document Name\",
\"lifecycle__v\": \"In Review\"
}"
https://{{vaultDNS}}/api/{{version}}/objects/documents/0000000000004EDDELETE // Delete a document
--header "Authorization: {{sessionId}}"
https://{{vaultDNS}}/api/{{version}}/objects/documents/0000000000004EDGET // Retrieve document details
--header "Authorization: {{sessionId}}"
--header "Accept: application/json"
https://{{vaultDNS}}/api/{{version}}/objects/documents/0000000000004EDGET // Retrieve all documents
--header "Authorization: {{sessionId}}"
--header "Accept: application/json"
https://{{vaultDNS}}/api/{{version}}/objects/documents