Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Power Query API Authentication

I want to connect to data at https://www.space-track.org/.   It requires an API connection.   I can't seem to figure it out in the normal authentication way or via PowerQuery. I tried this and d...
  • ams1's avatar
    ams1
    3 years ago

    Hi Anonymous 

     

    Yeah, we had the wrong Content-Type - give below a try:

     

    let
        url = "https://www.space-track.org/ajaxauth/login",
        identity = "change_this",
        password = "also_change_this",
        query = "https://www.space-track.org/basicspacedata/query/class/boxscore",
        headers = [#"Content-Type" = "application/x-www-form-urlencoded"], // this was the problem
        response = Web.Contents(url, [
            Headers = headers, 
            Content = Text.ToBinary(
                "identity=" & identity & "&password=" & password & "&query=" & query
            )
        ]),
        jsonResponse = Json.Document(response)
    in
        jsonResponse

     

    I actually tested it ğŸ˜Š

     

    Please mark this as ANSWER if it helped.

     

    P.S.: I saw there are some rate limiting guardrails in place on their side -> don't press the refresh button too often