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
Winter 26 Update Using LWC as Local Actions in Screen Flows

The Salesforce Winter Release 2026 introduces powerful AI-driven updates focused on automation, productivity, and smarter CRM experiences. From major enhancements in Salesforce LWC to improved Salesforce Flow local action capabilities, the release helps developers and admins build faster, more scalable Salesforce solutions. The Salesforce Winter 26 release also reflects Salesforce’s growing focus on AI-powered workflows, […]

Read More
Automation Difference Between HubSpot and Salesforce Flow

Customer Relationship Management (CRM) systems help businesses manage customer interactions, sales processes, and marketing campaigns efficiently. Two of the most popular CRM platforms used worldwide are HubSpot and Salesforce. Both platforms provide automation tools that allow businesses to automate repetitive tasks, improve efficiency, and reduce manual work. However, the automation capabilities and design of these […]

Read More
Automating Customer Approval Using Salesforce Approval Process

In many financial or compliance-based applications, organizations need a structured way to review and approve important documents or financial data before they are finalized. For example, a company implemented a Salesforce approval process to validate Customer’s ITR (Income Tax Return) details to ensure that high-income cases are reviewed by senior authorities while keeping the process […]

Read More
How to Automatically Create Messaging Consent Using Record Triggered Flow in Salesforce

Automating messaging consent in Salesforce is essential for maintaining compliance and scaling customer communication. In this guide, you’ll learn how to auto-create OPT-IN Messaging Consent records using a Record-Triggered Flow, eliminating manual work while ensuring accurate, real-time consent capture. If you’re searching for a reliable way to automate consent tracking in Salesforce without Apex and […]

Read More
How We Built a Structured Prospecting System Using HubSpot’s Prospecting Agent

Outbound prospecting doesn’t fail due to lack of effort, it breaks down when there is no structured system behind it. Many teams either rely heavily on manual outreach or expect automation tools to handle the entire process, often leading to inconsistent results and low-quality engagement. At HIC, we take a more balanced and scalable approach. […]

Read More
Apollo to HubSpot Integration Sync Contacts and Companies

Apollo is one of the most powerful prospecting tools for finding verified contacts and company information. HubSpot is a leading CRM used to manage contacts, companies, deals, and sales activity. When we integrate Apollo with HubSpot, we can automatically sync new prospects into HubSpot, along with enriched data like email, phone number, job title, and […]

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
Canada Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818