AutoTools Json read error with new NWS api

Discussion in 'AutoApps' started by svrwxnut, May 5, 2017.

  1. svrwxnut

    svrwxnut New Member

    Joined:
    May 5, 2017
    Messages:
    2
    Likes Received:
    0
    So I'm trying to use Json Read to pull in data from the new NWS api. I put in the url (https://api.weather.gov/points/34.3899,-103.0325/forecast for example) in the Json field and I set the root variable to %json. If I authenticate the url the correct data shows (the same as if you go to that url in a browser). However when I run the task I get an error with that last two lines saying:

    Error: 338929390
    java.io.FileNotFoundException: https://api.weather.gov/points/34.3899,-103.0325/forecast

    Also if I try a simple HTTP Get I do not get the data as I expect. I get the following:

    {
    "correlationId": "6ecec35a-fee3-44e8-8c4e-82e211a6d4d5",
    "title": "Unexpected Problem",
    "type": "https://api.weather.gov/problems/UnexpectedProblem",
    "status": 500,
    "detail": "An unexpected problem has occurred.",
    "instance": "https://api.weather.gov/requests/6ecec35a-fee3-44e8-8c4e-82e211a6d4d5"
    }


    So, I'm obviously not getting something right. I have a feeling it has something to do with the nws api, as I can get Json Read to work with the Wunderground api just fine. If it helps any, the nws api info can be found here: https://forecast-v3.weather.gov/documentation?redirect=legacy

    Thanks in advance.
     
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,477
    Likes Received:
    806
    Yeah, I can't get it to work either, sorry :/ Don't really know what is up with their servers, but I'm getting that error as well.
     
  3. svrwxnut

    svrwxnut New Member

    Joined:
    May 5, 2017
    Messages:
    2
    Likes Received:
    0
    Thanks for the reply. At least now I know I'm not crazy.
     
  4. jamesavery22

    jamesavery22 New Member

    Joined:
    Feb 22, 2018
    Messages:
    2
    Likes Received:
    0
    Did you find out why you're getting the 500 response? I'm getting the same thing. Hit the URL from the browser and it returns the json fine. Try to do it through an apache httpget and I get 500. If I use the same java code and only change the url to api.darksky.net I get the Json response OK. I noticed api.weather.gov does some kind of redirect on some api calls. The URL changes when hitting it from a browser. Of course the calls that don't redirect I still can't get anything but a 500 error. Anyone have any ideas?
     
  5. jamesavery22

    jamesavery22 New Member

    Joined:
    Feb 22, 2018
    Messages:
    2
    Likes Received:
    0
    Headers were missing...

    Need to have these two:

    HttpGet httpget = new HttpGet(url);
    httpget.setHeader("User-Agent", "<whatever you want>");
    httpget.setHeader("Accept", "application/vnd.noaa.dwml+xml;version=1");
     
  6. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,477
    Likes Received:
    806
    Interesting. :) Thanks! So using an HTTP GET in Tasker followed by a JSON Read should work right?
     

Share This Page