Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading base64 encoded CSV file #5316

Open
adhossain opened this issue Dec 3, 2024 · 0 comments
Open

Uploading base64 encoded CSV file #5316

adhossain opened this issue Dec 3, 2024 · 0 comments

Comments

@adhossain
Copy link

Description

I am trying to upload a CSV file using V2 API. the file is propoerly encoded with Base64. I am using Power Automate to perform the process. But I am receiving HTTP error 400 with description "base64Encoded": "Invalid content"

Steps to Reproduce

Step 1: Set Up Power Automate Flow
Trigger:

Start with a trigger that suits your needs, such as "When a file is created or modified in a folder" in SharePoint.
Initialize Variables:

Add an action to initialize a variable to store the CSV content.
Name: CSVContent
Type: String
Value: Leave it empty for now.
Get File Content:

Use the "Get file content" action to retrieve the CSV file from SharePoint.
Site Address: Your SharePoint site address.
File Identifier: The identifier of the file you want to retrieve.
Set CSV Content Variable:

Use the "Set variable" action to store the CSV content in the CSVContent variable.
Name: CSVContent
Value: @string(outputs('Get_file_content')?['body'])
Step 2: Convert File Content to Base64
Convert File Content to Base64 (Compose 1):

Add a "Compose" action to convert the file content to Base64.
Inputs: @base64(variables('CSVContent'))
Trim Base64 String (Compose 2):

Add another "Compose" action to ensure there are no extra characters or spaces in the base64 string.
Inputs: @Trim(outputs('Compose_1'))
Step 3: Prepare the Kobo API v2 Request
HTTP Action:
Add an HTTP action to send a POST request to the Kobo API v2.
Method: POST
URL: https://URL/api/v2/assets/form_ID/files/
Headers:

{ "Authorization": "Token YOUR_KOBO_API_TOKEN", "Content-Type": "application/json" }

Body:
{ "user": "https://URL/api/v2/users/YOUR_USERNAME/", "asset": "https://URL/api/v2/assets/form_ID/", "description": "Description of the file", "base64Encoded": "@outputs('Compose_2')", "metadata": { "filename": "ben_database.csv" } }

Expected behavior

The file should be upload propeorly without error

Actual behavior

HTTP error 400 with description "base64Encoded": "Invalid content"

Additional details

I am using Power Automate and Sharepoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant