Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Web.Contents with the Content option is only supported when connecting anonymously

Hi,   I am trying to connect to a data source via a POST request. To do this, I am creating a blank query that follows the following schema: let        url = "",       body = "{}",       head...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

    The error message you received indicates that the web service you are trying to connect to does not support sending data with authentication. One way to work around this issue is to encode the authentication information in the URL itself.

     

    To do this, you can modify your code as follows:

    let 
          url = "https://username:[email protected]/data",
          body = "{}",
    
          header = [#"Content-Type"="application/json"],
          result = Json.Document(Web.Contents(url,[Headers = header, Content=Text.ToBinary(body)]))
    
    in
          result

     

    Replace "username" and "password" with your actual credentials, and "api.example.com/data" with the URL of the web service you are trying to connect to. This should allow you to make a POST request with a body and basic authentication.

     

    How to Get Your Question Answered Quickly 

     

    If it does not help, please provide more details.

     

    Best Regards
    Community Support Team _ Rongtie

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