Forum Discussion

gcyr's avatar
gcyr
Frequent Visitor
8 years ago
Solved

Specified value has invalid HTTP Header characters

Hi,   I trying to connect to a secure API using a token and I received the following error:   Expression.Error: Specified value has invalid HTTP Header characters. Parameter name: name Details:...
  • gcyr's avatar
    gcyr
    8 years ago

    Hi v-jiascu-msft

     

    I found a solution to my problem.

    There was a couple of issues:

    My code should have been 

    let
    apiUrl = " <APIURL>",
    SqlQuery = " <SQL Query> "
    options = [Headers =[Token="<Token>", #"Content-Type" = "application/json"], Content = Text.ToBinary(SqlQuery)],
    result = Web.Contents(apiUrl , options)
    in
    result

    The Token should not have been in "". I don't know why HTTP did not recognize this header.

    The API only accepts POST method, so my SQLQuery should have been submitted as Content.

    I also had to specify the Content-Type.

     

    Thanks,

    Guillaume