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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
JoergSch
Frequent Visitor

Gateway ODATA datasource creation via API

Hello,

 

I am currently trying to create an OData datasource via the Gateway - Create Data source API (Gateways - Create Datasource (Power BI Power BI REST APIs) | Microsoft Docs).

 

When I put in the JSON and execute, I am getting below error.

 

{
  "error": {
    "code": "BadRequest",
    "message": "Bad Request",
    "details": [
      {
        "message": "Unexpected character encountered while parsing value: {. Path 'connectionDetails', line 11, position 27.",
        "target": "datasourceToGatewayRequest.connectionDetails"
      },
      {
        "message": "'datasourceToGatewayRequest' is a required parameter",
        "target": "datasourceToGatewayRequest"
      }
    ]
  }
}

 

The Input JSON looks as following:

 

{
    "datasourceName":  "My_ODATA",
    "credentialDetails":  {
                              "encryptedConnection":  "Encrypted",
                              "credentialType":  "Basic",
                              "credentials":  "mSTkW...dEwQ==",
                              "privacyLevel":  "Private",
                              "encryptionAlgorithm":  "RSA-OAEP"
                          },
    "dataSourceType":  "OData",
    "connectionDetails":  {\"url\":\"https://myURL.com\"}
}

 

Whats wrong with that?

 

How can I create an OData data source via the API?

 

Thanks

 

Joerg

 

1 ACCEPTED SOLUTION
JoergSch
Frequent Visitor

Thanks Xiaoxin,

 

I found the reason in the meantime. The parameter 

"useEndUserOAuth2Credentials": false,

was missing. The error message was a little bit misleading.

Joerg

View solution in original post

2 REPLIES 2
JoergSch
Frequent Visitor

Thanks Xiaoxin,

 

I found the reason in the meantime. The parameter 

"useEndUserOAuth2Credentials": false,

was missing. The error message was a little bit misleading.

Joerg

Anonymous
Not applicable

Hi @JoergSch,

If you not so sure these connection strings configured correctly.
You can try to directly config them on your gateway data source settings, then you can use the 'get Datasource' API to get the corresponding 'data source connections' as a referencce.

400 Bad Request - HTTP | MDN (mozilla.org)

Gateways - Create Datasource (Power BI Power BI REST APIs) | Microsoft Docs

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.