How to Return an Error Message to ImportData() - rest

I'm building a REST API, which is used mostly from Google Sheets at this point.
In Google Sheets I call my API using =ImportData(). I would like to return error messages that could be handled by =IFERROR() calls in Google Sheets, but I can't find any documentation / suggestions on how to do that.
I can return a string such as "#N/A - bad date in REST call", but IFERROR() would not know that this string is actually an error string.
Thanks!
Xavier

try:
=IF(A15="#N/A - bad date in REST call", ISNA(), A15)
where A15 is your IMPORTDATA()

Related

Thingsboard REST api call - variable response

Following this tutorial - weather using rest api calls - I’m trying to extend the example to gather the 1 hour accumulated rain data.
The Openweather api docs state:
If you do not see some of the parameters in your API response it means that these weather phenomena are just not happened for the time of measurement for the city or location chosen. Only really measured or calculated data is displayed in API response.
No accumulated rain volume means there is no rain section in the response. How do I deal with this in the rule engine? Essentially a conditional rule (if rain.1h is present, use rain.1h, else set rain.1h = 0)
Thanks
Rule Chain script is based on JavaScript. Response from thirdparty service will be in msg.
To check if rain.1h is in response:
if (msg.rain && msg.rain.1h) {
...
}

IBM Watson Clinical Annotator API Python SDK - adding optional parameter throws a 400

I am following the API documents for analyzing text via the API docs here and the examples on github here. When I add the optional parameter to the annotator to get all of the codes like this:
anno_cd = acd.Annotator(
name='concept_detection',
parameters = {'include_optional_fields':'medical_codes'})
I get this:
Error Occurred: Code 400 Message Bad Request CorrelationId
820af2f3-0b25-477a-bde5-20fc57fd4a4d
Does anyone see what I am doing wrong?
It was a problem with the way the parameters were set. You need to build a collection inside a collection. This works:
anno_cd = acd.Annotator(
name='concept_detection',
parameters = {"expanded": ["true"],"include_optional_fields":["medical_codes"]})

Retrieve TSX intra-day quote from Alphavantage

I've been able to get the daily quote for TSX marketing using this endpoint, and it has been working perfectly.
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=TSX:BTO&apikey={{key}}
But when I try to get intraday data (60 minutes) with the following request, it doesn't work.
https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&interval=60min&symbol=TSX:BTO&apikey={{key}}
RESPONSE
{
Error Message: "Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for TIME_SERIES_INTRADAY."
}
Is this because they don't offer intraday data for TSX or did I do anything wrong?
Thanks!
Use symbol=BTO.TO in your URL for both
Longer explanation:
There are a number of different methods for mapping tickers - generally the best method is:
symbol.exchange
See the wiki for more information

Got an error in the IBM Bluemix Weather Insights API used. Kindly help me out

I am referencing the documentation page here:
https://developer.ibm.com/bluemix/2015/10/23/ibm-insights-weather-available-in-bluemix/
But I'm getting the following error :
{"metadata":{"version":"1","transaction_id":"1:677162605","status_code":404},"success":
false,"errors":[{"error":{"code":"AGW-0114","message":"Failed to parse apiname"}}]}
My Constructed URL is :
https://****:*****#twcservice.mybluemix.net/api/weather/v2/forecast/&format=JSON&geocode=11.9310,%2079.7852&language=en-US&units=e
Kindly help me with this issue .
The constructed url needs to be like this:
https://twcservice.mybluemix.net/api/weather/v2/forecast/hourly/24hour?format=JSON&geocode=11.9310%2C79.7852&language=en-US&units=e
The differences are:
call the REST API /forecast/hourly/24hour rather than just /forecast
Add the ? at the end of the API so you pass the parameters
Add the %2C in the geocode to represent the ,
See swagger doc here

getting unexpected invalid filter.created_at[from] error message

I'm making this kind of SoundCloud API request:
https://api.soundcloud.com/tracks.json?q=electro&limit=10&client_id=<my-client-id-that-I-removed-intentionally>&created_at%5Bfrom%5D=2014%2F11%2F24%2012%3A03%3A04&offset=0
and since recently, I'm getting this response:
code: 400,
body:
{"errors":[{"error_message":"invalid filter.created_at[from] value: '2014/11/24 12:03:04'"}]}
My request should be fine, according to the official documentation:
https://developers.soundcloud.com/docs/api/reference#tracks
Could you please tell me if I'm doing something wrong?
Thanks for the support in advance.
The problem is in the date format. The docs say dashes should be used in dates:
created_at[from] date (yyyy-mm-dd hh:mm:ss) return tracks created at this date or later
So it will work when you specify the date like this: 2014-11-24 12:03:04 (not with slashes).
We at SoundCloud recently changed the behaviour of the API to return errors for all kinds of for invalid input in filters in order to be clearer about what is allowed and what can be expected.