Loading...

Integrating external healthcare platforms like Niko Health with Salesforce helps streamline document management and improve operational efficiency. In this guide, we will walk through the complete process of fetching a document from Niko Health using APIs and attaching it to a Salesforce account as a file.

This step-by-step implementation is useful when you want to automatically sync patient-related documents, invoices, prescriptions, or any external files into Salesforce.

Step 1: Set Up Named Credential

The first step is to configure a Named Credential in Salesforce. Named Credentials provide a secure and easy way to store authentication details and endpoint URLs for external systems.

As part of a Salesforce API integration, we will create a Named Credential for the Niko Health API endpoint. This helps avoid hardcoding sensitive information like usernames, passwords, or tokens directly in Apex code.

Why Use Named Credentials?

  • Secure authentication management
  • Simplifies API callouts
  • Supports OAuth and token-based authentication
  • Reduces maintenance effort

Configuration Includes:

  • Endpoint URL of Niko Health API
  • Authentication type
  • API credentials or token
  • Permission setup
  1. External Credentials:

    Step 1.1

  2. Name Credentials:

    Step 1.2 

  3. Name Principals:Step 1.3 
  4. Give the user permission to access this External Credential.Step 1.4 
  5. Give user external Credential Permission:Step 1.5 
  6. Once configured, Salesforce can securely communicate with the Niko Health system.

Step 2: Make First API Call (Fetch Documents List)

After setting up the Named Credential, the next step is to make an HTTP callout to the Niko Health API to fetch the list of available documents.

This initial step is a key component of a Salesforce Niko Health integration, enabling Salesforce to retrieve document metadata from the external system securely and efficiently.

Using Apex HttpRequest and HttpResponse, we send a GET request to the API endpoint.

Purpose of This API Call

The API returns metadata about documents, such as:

  • Document ID
  • File name
  • File type
  • Created date
  • Download URL

This response is usually returned in JSON format.

Example Flow

  1. Create HTTP request
  2. Set endpoint using Named Credential
  3. Set request method as GET
  4. Send request
  5. Receive response

This response will be used in the next steps to identify and download the required document.

Step 2

Step 3: Parse JSON Response

Once the API response is received, the JSON data must be parsed in Salesforce.

Salesforce provides methods like:

  • JSON.deserialize()
  • JSON.deserializeUntyped()

These methods help convert the raw JSON response into Apex objects or maps for easier access.

Why is Parsing Important?

The API response contains multiple fields and nested objects. Parsing helps extract specific values like:

  • Document ID
  • Download URL
  • File name

Without parsing, Salesforce cannot understand the JSON structure properly.

Best Practice

Create wrapper classes for structured and clean code when dealing with large API responses.

Step 3

Step 4: Extract Document Details

After parsing the response, the next step is to extract the required document details.

At this stage, we identify:

  • Which document needs to be downloaded
  • The exact download URL
  • File extension and name

Common Logic Used

You can filter documents based on:

  • Latest uploaded document
  • Specific file type
  • Matching patient/account information
  • Document category

These details are important because Salesforce will use them while saving the file.

Step 4

Step 5: Download the Document

Once the download URL is available, another API call is made to fetch the actual document file.

This API call generally returns the file content in binary format.

Process Includes

  • Creating another HTTP request
  • Sending GET request to download endpoint
  • Receiving file body from response

The document can be:

  • PDF
  • Image
  • Excel file
  • Text document

At this point, Salesforce receives the raw file data from Niko Health.

Step 5

Step 6: Convert File into Blob (Binary Large Data)

Salesforce stores files in Blob format. Therefore, the downloaded file content must be converted into a Blob before saving.

The HTTP response body is converted using:

Blob fileBody = response.getBodyAsBlob();

Why Blob Conversion is Required?

Blob is Salesforce’s binary data type used for:

  • PDFs
  • Images
  • Attachments
  • Documents

Without Blob conversion, the file cannot be stored in Salesforce Files.

Step 6


Step 7: Save File in Salesforce (ContentVersion)

Now the document is ready to be stored in Salesforce.

Salesforce Files are stored using the ContentVersion object. This approach strengthens Salesforce document management by centralizing files within the CRM and making them easily accessible to authorized users.

Required Fields

  • Title
  • PathOnClient
  • VersionData

Example Process

  1. Create ContentVersion record
  2. Add Blob data
  3. Insert the record into Salesforce

After insertion, Salesforce automatically creates a file in the Files section.

Benefits of Using ContentVersion

  • Modern Salesforce file storage
  • Better sharing capabilities
  • Version management support
  • Easy attachment to recordsStep 7


Step 8: Get ContentDocumentId

Once the ContentVersion record is inserted, Salesforce generates a related ContentDocumentId.

This ID is important because it represents the actual file stored in Salesforce.

Why Do We Need ContentDocumentId?

The Content Document Id is used to:

  • Link the file to Salesforce Account
  • Share files with users
  • Access file records later

You can retrieve it by querying the inserted ContentVersion record.

Final Step

Using ContentDocumentLink, the document can be attached directly to the Salesforce Account.

This completes the entire process to Fetch Document from Niko Health and Attach it to Salesforce Account, ensuring that users can access important files without leaving Salesforce.

Step 8


Conclusion

Integrating Niko Health with Salesforce for document synchronization improves automation and reduces manual work. By using Named Credentials, API callouts, JSON parsing, Blob conversion, and Salesforce Files, organizations can seamlessly manage external documents directly within Salesforce.

This approach provides:

  • Secure integration
  • Automated document handling
  • Better record management
  • Centralized file storage in Salesforce

Organizations looking to implement similar solutions can leverage expert Salesforce services and Salesforce integration services from HIC Global Solutions to build secure, scalable, and efficient healthcare integrations. With this implementation, healthcare and operational teams can access important documents without switching between systems.

Watch Live Demo

No Data Found.

Related Articles
How to Sync Order Records Between NikoHealth and Salesforce Using MultiSync Made Easy

In this guide, we’ll walk through how to synchronize Order records between NikoHealth and Salesforce using MultiSync Made Easy. Before proceeding, ensure that: NikoHealth is already authorized with Salesforce. Patient synchronization is already configured. The Order object exists in Salesforce. This Salesforce NikoHealth integration guide covers: NikoHealth → Salesforce Order Synchronization Salesforce → NikoHealth Order […]

Read More
How to Integrate Documents Between NikoHealth and Salesforce

Healthcare organizations manage a wide range of patient documents, from prescriptions and medical orders to other important records. Keeping these files updated across NikoHealth with Salesforce can be difficult when documents are uploaded and managed manually.  A reliable Salesforce document management process helps ensure patient files stay organized and accessible in one place. In this […]

Read More
How to Integrate Medical Records Between NikoHealth and Salesforce

Medical Records contain important patient diagnosis information used by healthcare providers for treatment, billing, authorizations, prescriptions, and order processing. With MultiSync Made Easy, organizations can simplify NikoHealth and Salesforce synchronization by automatically syncing Medical Records between both platforms while maintaining accurate Patient relationships. In this guide, we will configure: NikoHealth → Salesforce Medical Record Synchronization […]

Read More
How to Integrate Authorization Records Between NikoHealth and Salesforce Using MultiSync Made Easy

Authorizations are one of the most important components of the healthcare revenue cycle. They help providers track payer approvals, authorized units, approved amounts, HCPCS codes, and authorization periods before services are delivered or billed. When authorization data is managed across different platforms, keeping records updated manually can become difficult. A proper Healthcare CRM Integration helps […]

Read More
How to Integrate Google Gemini Vertex AI with Salesforce Using Named Credentials

Generative AI is transforming how businesses automate workflows, generate content, and improve productivity. By integrating Google Gemini Vertex AI with Salesforce, developers can build AI-powered CRM experiences directly inside Salesforce applications. Using Salesforce Named Credentials and External Credentials, businesses can securely authenticate with Google Vertex AI APIs without hardcoding authentication tokens or secrets in Apex […]

Read More
How to Integrate Insurance Records Between NikoHealth and Salesforce

Keeping insurance records synchronized between NikoHealth and Salesforce helps reduce manual work and keeps your data accurate across both platforms. In this guide, we’ll show you how to set up the NikoHealth integration using MultiSync Made Easy. Before proceeding further, make sure: NikoHealth is already authorized with Salesforce. Patient synchronization is already configured. The Insurance […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203239658
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
CA Flag Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818