JSON Api with headers

I have a function that I’ve created that works with a JSON api with a query

let Source = (RelativePath) =>

// function to add as a custom column to pull in relative path from table using the name of the api call
let
Source = Json.Document(Web.Contents(
“https:/********/”,
// url remains static
[
RelativePath = RelativePath,
Query =
[
token=Token // token is parameterised
]
]
)),
#“Converted to Table” = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
#“Converted to Table”

in Source

Which works and I can add as a custom column to the table that holds the relative path within a column.

I’d like to try to do the same but using a url with a Headers field but am struggling.

The url is structured like this:

= Json.Document(Web.Contents(“https:///RelativePathstoredincolumn", [Headers=[#“X-SiteToken”="****”]]))

and I want to use a Headers parameter instead of query and token as above. I think it’s because it’s a list within a list and has special characters in it. Any suggestions?

//[Headers=[#"“X-SiteToken”"=""***********""]]))"

@Sue,

I’d like to try to assist with this, but am struggling only being able to (poorly) visualize what’s going on here. Is this by any chance a public website that I could obtain a token for, so I can get my hands dirty working with exactly what you’re seeing? Thanks!

  • Brian
1 Like

Brian, I got it to work two minutes ago, I needed to make the Relative Path a list type so that when you put it in the custom function column you can specify the column and therefore row to use.
I’ll add it to the analyst hub later, it’s been driving me crazy

1 Like

@Sue,

Nice. I know well that frustrating feeling of “why won’t this work? - this should work!” , but super satisfying when you finally figure it out.

  • Brian
1 Like

@Sue,

I would suggest reposting this in a new topic, and then deleting the post from this thread. Makes it very difficult for people to find (either those looking to provide solutions or those with a similar question) if the question is buried within an already solved thread on an unrelated topic.

Thanks.

  • Brian

Good point, will do

Hi @Sue! I hope that you are having a great experience using the Support Forum so far. We’ve recently launched the Enterprise DNA Forum User Experience Survey, please feel free to answer it and give your insights on how we can further improve the Support forum. Thanks!