Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Sebas2905
Frequent Visitor

Error using R script transforming data

Hi 

 

I want to use R in Power Query to create a HMAC-SHA1 signature in Power Query. The R-Script I want to run is the following:


library(httr)

key <- "Key"
string <- "String"

signature <- sha1_hash(key, string, method = "HMAC-SHA1")

 

This script works perfectly in RStudio. To use it in Power Query I created a table with a Key column and a String column by using Enter Data. I want the R script to create a signature for every combination of Key and String on every row. The table I created is this:

Knipsel.PNG

 

To run the script I added the step Run R script1 and added the following R script:

 

# 'dataset' holds the input data for this script

library(httr)


key <- dataset$"Key"
string <- dataset$"String"

signature <- sha1_hash(key, string, method = "HMAC-SHA1")

output <- dataset

output$signature <- signature

 

This results in the following error:

 

DataSource.Error: ADO.NET: R script error.
Error in rawstringhash(x, "sha1", key) :
Argument 'x' must be raw or character vector.
Calls: sha1_hash -> <Anonymous> -> rawstringhash
Execution halted

Details:
DataSourceKind=R
DataSourcePath=R
Message=R script error.
Error in rawstringhash(x, "sha1", key) :
Argument 'x' must be raw or character vector.
Calls: sha1_hash -> <Anonymous> -> rawstringhash
Execution halted

ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.R.Exceptions.RScriptRuntimeException

 

Does anyone know why this script won't run? If I replace the parameters key and string with plain text the script works fine, but doesn't calculate the signature per row. So it doesn't recognize my rows as valid parameters in the R script.

 

# 'dataset' holds the input data for this script

library(httr)


key <- "Key"
string <- "String"

signature <- sha1_hash(key, string, method = "HMAC-SHA1")

output <- dataset

output$signature <- signature

 

Knipsel1.PNG

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Sebas2905 

Check if changing dataset$column1 to as.character(dataset$column1) would work.

 

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
michaelsh
Kudo Kingpin
Kudo Kingpin

@Sebas2905  @v-juanli-msft 

Do you know if it (R script) will work in the service...?

@michaelsh 

 

it works if you use a gateway (enterprise or personal) with R installed on it. 

best regards, Sebastiaan

v-juanli-msft
Community Support
Community Support

Hi @Sebas2905 

Check if changing dataset$column1 to as.character(dataset$column1) would work.

 

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Maggie,

 

It works! Thanks.

 

Best regards,

 

Sebastiaan

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors