Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DataSource.Error : Web.Contents failed to get contents from « https://XXXXXXXXX » (500)

Hi,

 

I get data from an API through a connector. 

It works well except for some inputs which return the following error : 

DataSource.Error : Web.Contents failed to get contents from « https://XXXXXXXXX » (500) : Internal Server Error

I know that these inputs do have data to be returned (those who don't have data still return an empty table). 

 

Do you have any advice on how to solve this ? 

 

Thanks in advance. 

5 Replies

  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    Community Support

    Hi Anonymous,

     

    I suggest that you first test the availability of the API directly using one of the other tools. For example, postman. Make sure the headers information is correct. It may be that some of your headers are missing, such as connect-type or User-Agent.

     

    500 statu code is mostly the server encountered an unexpected condition that prevented it from fulfilling the request.

    500 Internal Server Error - HTTP | MDN (mozilla.org)

     

     

    Best Regards

    Community Support Team _ chenwu zhu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • SofBL's avatar
    SofBL
    Advocate II

    I even expirienced this when my authentication header was not in the right order. 

     

    It is always adviced to contact the support team of the API you are trying to connect. 

    Secondly first try to connect to the api using Postman, if that works you know you have the right header and possible body in place

    good example of a platform that takes care and delivers support on their API is mediavalet. You can refer to your api supplier to their website to show how good api documentation looks like. They also deliver an app collection for postman so you know exactly how the api should work. 
    MediaValet API


    now for that specific solution this is the way to go: 
    I expirenced that if you do this the application/json content type is changed to application/x-www-form-urlencoded by power bi

    let
    TokenReq = Web.Contents("https://login.mediavalet.com/connect/token", [
    Headers = [
    #"Content-Type" = "application/x-www-form-urlencoded",
    Authorization = Base64cred
    ],
    Content = Text.ToBinary("grant_type=password&username="& Usr & "&password=" & Passw & "&scope=api")
    ]),
    TokenJson = Json.Document(TokenReq),
    Token = TokenJson[access_token],
    Token2 = Token,
    SearchReq = Web.Contents("https://api.mediavalet.com", [
    RelativePath = "assets/search",
    Headers = [
    #"Ocp-Apim-Subscription-Key"= SubscriptionKey,
    #"Content-Type" = "application/x-www-form-urlencoded",
    Authorization = "Bearer " & Token
    ],
    Content = Json.FromValue([
    search = "PietjePuk",
    count = 1,
    offset = 0,
    sort = "record.createdAt D",
    searchFields = "attributes",
    includeSoftDeleted = true,
    filters = "DateUploaded GE 2025-02-22T01:55:39.496Z"
    ])
    ]),
    Jsonresult = Json.Document(SearchReq)

    in
    Jsonresult




  • I know this has been marked as solved but what worked for me was simply removing the percentage from the Sharepoint File's name

  • I double clicked on the Source query step in power query and changed the view mode to Default instead of All. That fixed it.
    My issue was with a sharepoint list.