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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Yrstruly2021
Helper V
Helper V

Help with RMS Online API Token Authentication in Power Query – 400 Bad Request Error

 

Hi everyone,

I’m currently integrating the RMS Online (Staging) API into Power BI using Power Query (M language) to extract data such as voyage information.

My goal is to authenticate using the /api/v1/service/token/password endpoint to obtain a Bearer token, which I can then reuse to query endpoints like /api/v1/voyage/find_all.


What I’ve done so far:

I built a Power Query script that constructs a JSON body and sends it to the RMS token endpoint.
Here’s the core part of the script:

 

 
let BaseUrl = "https://staging.rms-online.co.za", ClientId = "datalink", Secret = "xxxxxxxxxxxx", Username = "sandb...

 

 

The issue:

When I run this query, I receive:

 

 
DataSource.Error: Web.Contents failed to get contents from 'https://staging.rms-online.co.za/api/v1/service/token/password' (400): Bad Request

 

 

Details:

 

 
DataSourceKind = Web DataSourcePath = https://staging.rms-online.co.za/api/v1/service/token/password Url = https://staging.rms-online.co.za/api/v1/service/token/password
 

I’ve confirmed that:

  • The URL is reachable.

  • My JSON body is being built correctly.

  • Credentials in Power BI are set to Anonymous for the domain.


    What I’ve tried so far:

  • Sent the same body using Postman (and it works correctly there).

    1. Tried both:

    2. Content = Json.FromValue(TokenBodyRecord)

    3. and form-encoded body:

       
      Content = Text.ToBinary("id=datalink&secret=33xAI2zjZ6Tpn6oD&username=sandbox&password=vfcAQt")
      • Changed the header between:

        • "application/json"

        • "application/x-www-form-urlencoded"

          Both attempts return 400 Bad Request in Power BI.


          What I’m trying to achieve:

          I want to:

          1. Successfully retrieve an access_token from the RMS staging environment in Power Query.

          2. Use that token to call endpoints such as:

             
            https://staging.rms-online.co.za/api/v1/voyage/find_all

            and convert the returned JSON into a table.

1 ACCEPTED SOLUTION

Hi @Yrstruly2021 ,

If you believe Power Query request is not going as intended, the key step is to verify whether Power Query is sending the request payload in the same way Postman does, this step will compare the actual HTTP requests between power query and Postman.

 Capture the POST request in Postman (which works), then capture the same request from Power Query using a tool such as Fiddler. Comparing them side-by-side will show if there are differences in headers (such as Content-Type), character encoding, or how the body is formatted (e.g., JSON vs x-www-form-urlencoded). Once we see exactly what differs, we can adjust the Power Query request to match the known working format. 

I hope this information helps. Please do let us know if you have any further queries.
Thank you


View solution in original post

5 REPLIES 5
v-nmadadi-msft
Community Support
Community Support

Hi @Yrstruly2021 ,

May I check if this issue has been resolved? If not, Please feel free to contact us if you have any further questions.


Thank you

v-nmadadi-msft
Community Support
Community Support

Hi @Yrstruly2021 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.


Thank you.

v-nmadadi-msft
Community Support
Community Support

Hi @Yrstruly2021 ,
Thanks for reaching out to the Microsoft fabric community forum.

In Power BI, POST requests made through Web.Contents can only be executed when the data source is configured with Anonymous authentication. So please re check if the Post request from Power Query is going through anonymously.

Also, verify that the URL or API endpoint you’re calling is accurate and matches the one specified in the API documentation.


I hope this information helps. Please do let us know if you have any further queries.
Thank you

 

I’ve double-checked and confirmed that my Power BI data source is configured as Anonymous for https://staging.rms-online.co.za.

I’ve also verified that the API endpoint is correct — it matches the one provided in the official RMS Online API Integration Guide:

 

 
POST https://staging.rms-online.co.za/api/v1/service/token/password
 

Despite that, I’m still receiving a 400 Bad Request error when the request is sent from Power Query, even though the same credentials and JSON body work correctly when tested in Postman.

It seems that Power Query may be formatting or encoding the request body differently (perhaps due to how it serialises JSON or sets headers).

Would you happen to know whether RMS’s token endpoint requires a particular header, encoding format, or perhaps does not accept JSON payloads but only x-www-form-urlencoded content?

Any additional insights or examples of working POST token requests from Power Query would be highly appreciated.

Hi @Yrstruly2021 ,

If you believe Power Query request is not going as intended, the key step is to verify whether Power Query is sending the request payload in the same way Postman does, this step will compare the actual HTTP requests between power query and Postman.

 Capture the POST request in Postman (which works), then capture the same request from Power Query using a tool such as Fiddler. Comparing them side-by-side will show if there are differences in headers (such as Content-Type), character encoding, or how the body is formatted (e.g., JSON vs x-www-form-urlencoded). Once we see exactly what differs, we can adjust the Power Query request to match the known working format. 

I hope this information helps. Please do let us know if you have any further queries.
Thank you


Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.