You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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
The text was updated successfully, but these errors were encountered: