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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
jnickell
Helper V
Helper V

Assistance with converting CURL request into PowerQuery

I have a successful CURL request to Box.com's API, but I'm uncertain how to translate that into a successful PowerQuery  statement.

curl --location --request "POST" --header "Content-Type: application/x-www-form-urlencoded" --data-urlencode "client_id=<clientID>" --data-urlencode "client_secret=<ClientSecret" --data-urlencode "grant_type=client_credentials" --data-urlencode "box_subject_type=enterprise" --data-urlencode "box_subject_id=<companyID>" "https://api.box.com/oauth2/token"

I've successfully used the result that was returned by this CURL query to get a file from Box.

What I have so far, gets me a 400 error message.

let
  LoginURL = "https://api.box.com/oauth2/token",
  PostBody = [
      #"client_id" = "<clientID>",
      #"client_secret" = "<clientsecret>",
      #"grant_type" = "client_credentials",
      #"box_subject_type" = "enterprise",
      #"box_subject_id" = "<companyID>"
    ],
  Header = [#"content-type"="application/x-www-form-urlencoded"],
  PostBodyEncoded = Uri.BuildQueryString(PostBody),
  out = Json.Document(Web.Contents(LoginURL,[Content=Json.FromValue(PostBodyEncoded),Headers=Header]))
  
in
  out

 I don't have much experience with CURL or Web.Contents so it's been painful to get to this point.  
Box's documentation on the API is focused on SDK implementations
https://box.dev/guides/authentication/jwt/without-sdk//#code-samples
This is my second time to try and post this. Hopefully this time it will actually go through.  I appreciate any assistance you might be able to give. 

 

1 ACCEPTED SOLUTION
jnickell
Helper V
Helper V

I guess sleep is a good thing.  I took another look at this forum post and was able get a working configuration in my situation as well.
https://community.powerbi.com/t5/Desktop/requests-to-a-JWT-API-token/td-p/1097823

 

The difference was changing 

Content=Json.FromValue(PostBodyEncoded)

 to

Content=Text.ToBinary(PostBodyEncoded)

View solution in original post

1 REPLY 1
jnickell
Helper V
Helper V

I guess sleep is a good thing.  I took another look at this forum post and was able get a working configuration in my situation as well.
https://community.powerbi.com/t5/Desktop/requests-to-a-JWT-API-token/td-p/1097823

 

The difference was changing 

Content=Json.FromValue(PostBodyEncoded)

 to

Content=Text.ToBinary(PostBodyEncoded)

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.