New Member
October 28, 2023
I have gone through this
I have done EXACTLY the same steps to try to connect to nasa
https//api.nasa.gov/insight_weather/?api_key=DEMO_KEY&feedtype=json&ver=1.0
but what I got is an error message saying "Impossibile to resolve the remote name: 'api.nasa.gov' "
____________
BTW This is part of my attempt to understand how to actually connect to a webservice of mine where I have a token.
My headers include an authorization Bearer or Token
Something that in "M" language should be similar to
let source
source = Json.Document(Web.Contents("http://213.215.231.4/swappX/api/ASC_Anni",
[Headers=[Bearer="my token"]]
))
in
source
It's not working and I can't find any way to make it work
I also went through
but this is not working for me.
Any help is highly appreciated
New Member
October 28, 2023
I copy
https://api.nasa.gov/insight_weather/?api_key=DEMO_KEY&feedtype=json&ver=1.0
and add a connection "from Web" but the answer is "Impossible to solve the remote name "api.nasa.gov"".
_________________________
I've got an API which is public and I can see it from the web. if I type https://jsonplaceholder.typico......com/posts I get the json.
If I use Power query IT WORKS if I write
letSource= Json.Document(Web.Contents("https://jsonplaceholder.typicode.com/posts"))inSource
let
Source= Json.Document(
Web.Contents(
"https://jsonplaceholder.typicode.com/posts",
[Content=
Json.FromValue(
[title="foo", body ="bar", userId = 1]
)
]))
in
Source
is giving my an error. (again impossible to solve the tremote name jsonplaceholder.tyipicode.com)
It's like if I couldn't add any additional headers...which prevents me from adding authentication...
Infact I have my own API which I try to connect to through:
let
Origine = Json.Document(Web.Contents("http://213.215.231.4/swappX/api/ASC_Anni",
[Headers=[#"x-api-key"="...my APItoken"]]))
in
Origine
This is one of the ways to pass an api key which I have found on the web (one of many).
But it says credentials are not valid...in the end what I need is this, and previous steps are for me necessary just to understand how it works and then to pass a token. I have found many different versions on the web on how to add the headers payload but none of them works in my case....
Any help is appreciated, thanks
October 5, 2010
Hi Nicola,
I can't reproduce any of your issues.
If you click the link you pasted to the NASA API it returns JSON data. Therefore the error you are receiving is not due to the API.
As the error states something about "impossible to solve the remote name" it would suggest some kind of name (DNS) lookup issue. As such that's a network/PC configuration issue.
That said, if you simply click the link to the NASA API and get a result returned, your PC is able to resolve the domain name correctly. In which case I can't really shed any light on to why you are getting an error.
I tried the sample code you provided for the jsonplaceholder website and both queries successfully return data.
Have you tried just visiting the URL's for these queries and seeing if they return a valid response?
In terms of how to provide authorization headers, I wrote about this here Connecting to an OAuth API with Power Query
If you download the Excel workbook and examine the query you'll see that I pass the authorization as a header like this
data= Json.Document(Web.Contents(api_url,
[
RelativePath = path,
Query = [end_date=endDate, start_date=startDate, fields=fields],
Headers = [#"Authorization"="Bearer "&token,#"Content-Type"="application/json"]
]
Regards
Phil
1 Guest(s)