Survey123: Using Pulldata to Access Open Weather/MSN Weather Parameters

3879
9
Jump to solution
01-11-2021 01:57 PM
dgray
by
New Contributor III

Hello,

 

I would like some help in getting Survey123 to populate attribute fields with weather parameters.  It looks like there used to be a document on how to do this, but it’s no longer available. 

 

https://community.esri.com/t5/arcgis-survey123-questions/using-pulldata-to-gather-live-weather-data/...

 

This site points to another link with some instructions:

https://community.esri.com/t5/arcgis-survey123-blog/extending-survey123-smart-forms-with-custom-js-f...

 

It looks like MSN Weather also has parameters:

https://docs.microsoft.com/en-gb/connectors/msnweather/

Open Weather has this information:

https://openweathermap.org/api/one-call-api#how

However, I’m unfamiliar with Javascript, and don’t know how to apply this information to my specific problem.  I need a step-by-step breakdown of how to use a pulldata function to get parameters either from Open Weather or MSN Weather, showing a specific javascript code example that I can use as a model from which to copy.  The actual pulldata function is straightforward, but I need help mostly with the JS part.

0 Kudos
1 Solution

Accepted Solutions
dgray
by
New Contributor III

I have found a solution for this:

There is a sample Survey123 template in Survey123 Connect that provides the code:

  1. Open Survey123 Connect
  2. Select New Survey
  3. Select Samples
  4. In the search bar, type JavaScript
  5. Select Create Survey

The sample survey has a Working with a Third-Party API - Open Weather example.
Once the sample survey is created, you will have access to the xls form as well as the JavaScript files used to create the survey. You can reference the pulldown expression and the Javascript code when creating your survey. 

The sample code provides an API key, but you can sign up to OpenWeather and get your own key.  There's a lot of documentation on making API calls:

https://openweathermap.org/api

The one downside I discovered, however, is that using a free OpenWeather account you can get CURRENT weather parameters, and hourly forecast data, but unfortunately you cannot get a daily forecast summary (e.g. min and max temperature) without paying for an OpenWeather subscription.

View solution in original post

9 Replies
dgray
by
New Contributor III

I have found a solution for this:

There is a sample Survey123 template in Survey123 Connect that provides the code:

  1. Open Survey123 Connect
  2. Select New Survey
  3. Select Samples
  4. In the search bar, type JavaScript
  5. Select Create Survey

The sample survey has a Working with a Third-Party API - Open Weather example.
Once the sample survey is created, you will have access to the xls form as well as the JavaScript files used to create the survey. You can reference the pulldown expression and the Javascript code when creating your survey. 

The sample code provides an API key, but you can sign up to OpenWeather and get your own key.  There's a lot of documentation on making API calls:

https://openweathermap.org/api

The one downside I discovered, however, is that using a free OpenWeather account you can get CURRENT weather parameters, and hourly forecast data, but unfortunately you cannot get a daily forecast summary (e.g. min and max temperature) without paying for an OpenWeather subscription.

DanLissick
New Contributor III

Has anyone create a survey to pull historical weather data with the new One Call 30.0 API?

0 Kudos
MFazio
by
New Contributor III

@DanLissick , have you had any luck with this? I've been working with the API and have successfully gotten a JSON response, however I cannot get the pulldata(@json) to properly populate the fields.

0 Kudos
DanLissick
New Contributor III

@MFazio I have been able to pull current weather into a survey but not historical weather yet.

0 Kudos
MFazio
by
New Contributor III

@DanLissick  I've been able to successfully  pull historical data with the Open Call 3.0 API by getting a new API key that allows access to that version. It appears they require a subscription for the Open Call API. If you still have any questions, I'm happy to try and help. 

DanLissick
New Contributor III

I have it on my list to try a different API source for historical data. If I am successful, I will reach out.

0 Kudos
janderson_ksninc
Occasional Contributor

I followed your instruction but I'm having problems with the API I generated. I signed up at the link you provided and created an API. When I try my API, all I get is the lat/long but no JSON response, location weather, or temperature. Would this have to do with the script or would it be something else?

0 Kudos
MFazio
by
New Contributor III

@janderson_ksninc if you can alter your JS script to return the response value it will help in debugging the response. In my case, the API key wasn't valid for the Open Call 3.0 API. Also, in the pulldata request in your Survey123 form, make sure you are parsing the JSON data properly as they reformatted it with the new API and it does not match with the default provided in the ESRI example. 

0 Kudos
MT_JenAmes
New Contributor III

Has anybody had luck with having accurate information from OpenWeather? I am successfully pulling info into my form, but values are way off. For example, Accuweather is telling me that temp is 17 C, but my pulldata from OpenWeater is saying 26 C, and the map on OpenWeather reads the nearest city as 15 C. Nearly all of the other values that I'm getting populating my form are off also. Any ideas?

0 Kudos