cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Unable to export object using /api/2.0/workspace/export API

hims_2021
New Contributor

Hi ,

I was using /api/2.0/workspace/export API in power automate workflow to export to excel from data brick to sharepoint. This functionality was working fine till yesterday. Today onwards it is throwing below error while calling the API

Action 'HTTP_Request_to_get_data_from_databrick' failed: Http request failed as the content was not valid: 'Unable to translate bytes [9A] at index 11 from specified code page to Unicode.'.

API URL used: https://databrick server /api/2.0/workspace/export?path=/filepath/test.xlsx&format=SOURCE&direct_download=true

Please let me know if any one any clue to correct this. 

#API

1 REPLY 1

lingareddy_Alva
Honored Contributor II

@hims_2021 

This error indicates an encoding issue when trying to export an Excel file from Databricks to SharePoint via Power Automate. The specific error message about being "Unable to translate bytes [9A] at index 11" suggests that Power Automate is having trouble processing binary content that's being returned from the Databricks API.

1. Use Base64 Encoding for Binary Content
The most reliable solution for transferring binary files through Power Automate is to use base64 encoding:
python# In your Databricks notebook
import base64
import os

# Path to your Excel file
file_path = '/dbfs/path/to/your/test.xlsx'

# Read the file in binary mode
with open(file_path, 'rb') as f:
file_content = f.read()

# Encode file content as base64
base64_content = base64.b64encode(file_content).decode('utf-8')

# Return the base64 encoded content
dbutils.notebook.exit(base64_content)
Then in Power Automate:

Run the notebook that returns base64 content
Decode the base64 content
Save the decoded content to SharePoint

2. Modify Export API Usage
The issue may be with how the API is handling the binary file. Try these adjustments:
Option A: Use different format parameter
https://databrick-server/api/2.0/workspace/export?path=/filepath/test.xlsx&format=DBC&direct_downloa...
Option B: Use the /api/2.0/dbfs/read endpoint instead
Since you're trying to export an Excel file, it might be better to use the DBFS API directly:
https://databrick-server/api/2.0/dbfs/read?path=/dbfs/filepath/test.xlsx

LR

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now