Building an api JSON query that needs headers

CatParky

New member
Joined
Jul 18, 2018
Messages
1
Reaction score
0
Points
0
Excel Version(s)
365
Hi,

I'm having a first attempt at working with an api in PowerQuery and have run into a stumbling block. I have an api that runs brilliantly in PostMan and another online service, but I can not figure out how to get it to work in excel.

The full query I have copied from a working alternate source is :

Code:
GET https://api.teamgate.com/v4/deals?embed=customFields&isDeleted=no&limit=1000
X-App-Key:[value redacted]
X-Auth-Token:[value redacted]

How do I pass the x-app-key and token as headers ?
Any advise is welcome

I have tried

Code:
let
Source = Json.Document(Web.Contents("https://api.teamgate.com/v4/deals?embed=customFields&isDeleted=no&limit=1000",
[Query = [
#"X-App-Key" = "123123123",
#"X-Auth-Token" = "abcabcabc"]]
))
in
    Source

and

Code:
let
	
Source = Json.Document(Web.Contents(https://api.teamgate.com/v4/deals?embed=customFields&isDeleted=no&limit=1000,
     [
         Headers = [#"X-App-Key"="123123123",
                    #"X-App-Token"="abcabcabc",
                    #"Content-Type"="application/json"],
         Content = Text.ToBinary("") 
     ]
 ))

in
    Source

however I am hit with "access to the resource is forbidden" and requires me to edit credentials. The answer is always Access to the resource is
forbidden.
 
Last edited:
Your last attempt looks like it has the right form, perhaps try moving the query string into the Content and getting rid of the Content-Type.


Code:
let
	
Source = Json.Document(Web.Contents("https://api.teamgate.com/",
     [
         Headers = [#"X-App-Key"="123123123",
                    #"X-App-Token"="abcabcabc"
                    ],
         Content = Text.ToBinary("v4/deals?embed=customFields&isDeleted=no&limit=1000") 
     ]
 ))

in
    Source

Norm
 
Back
Top