AutoWeb API creation hurdles

Discussion in 'AutoApps' started by lajan, Nov 18, 2018.

  1. lajan

    lajan New Member

    Joined:
    Nov 17, 2018
    Messages:
    8
    Likes Received:
    0
    I've spent some time attempting to create a new API in AutoWeb, but I am making less progress than I would hope.

    One main difficulty, now that I've set the inputs up, mostly (other than authentication, which the interface will not allow me to specify, or permit this as an option, so it ends up as a "variable" when processing inputs), is that I cannot debug the output. Through a web interface of the site, I know what the JSON output is supposed to be, it begins with a "[", but AutoWeb tells me that the output from *its* API call doesn't begin with a "[". How can I debug this? It's impenetrable, from the standpoint of a novice.

    Looking to the output configuration, it also looks like it will be a slog, but if we have no access within the interface to the outputs, it will be utterly impossible. I've also tried using both CSV and XML output via the API call, and it does not appear to be properly parsing much, so I have little idea at this point as to how to properly format this, despite looking over many of the docs.

    Thanks in advance for any assistance that people can offer, here.
     
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,477
    Likes Received:
    806
    Hi there.
    To use other means of authentication you should select other kinds of Authentication Types. That will make the required authentication fields show up.

    About checking the output of a call, enable system logs in AutoWeb and then check the app's logs. The output should be listed there.

    About generating the outputs, if you long press an API Endpoint, you have the option to do it automatically.
    Hope this helps!
     
  3. lajan

    lajan New Member

    Joined:
    Nov 17, 2018
    Messages:
    8
    Likes Received:
    0
    When I edit the generic API call fields to include a secret key authentication, the change does not appear to persist, it reverts to "No Authentication"; maybe this is meant to happen, but I find it confusing, and I don't know how to configure it properly, to have the authentication take place in a manner that is not an "API Key" variable.

    I appreciate the response, and I am still a very new hand, so I would also like to ask how, for this plugin alone, AutoWeb, one can enable system logs? The only option of this sort appears to be available in Tasker, itself, but are there separate, independent plugin log settings somewhere? Obviously, I'm trying to get a very small sliver of a log, and using LogCat to do this is like sifting through the desert.

    A great feature to add to this, I would request, would be to show users what their actual API calls will look like, plus to get a sample output to file, to be able to make this process more streamlined. I'm looking at logs, and I'm not able to find the API call information very easily.

    Thanks for your assistance so far.
     
  4. lajan

    lajan New Member

    Joined:
    Nov 17, 2018
    Messages:
    8
    Likes Received:
    0
    Looking at the logs, I think there is a bug of some kind, as it's calling for an "option2" instead of the actual argument, from the list of three possible input options, even when there is a defined default value, that being "application/json"--which goes a long way in explaining why it doesn't get an expected json value!

    Here is what is being called now, it's an air quality request from the EPA's AirNow site:
    docs.airnowapi.org/aq/observation/zip%20Code/current/Code/current?zipCode=90210&API_KEY={mykey}&distance=0&format=option2&aq%2Fobservation%2Fzip+Code%2Fcurrent%2FCode%2Fcurrent=

    I've fixed it up a bit since then, there was an obvious typo (no space between "zip" & "Code"), and it decided that the path was going to be "Code/current", which I removed, but so, now it still passes an argument of "option2" for the format. And, to be honest, I can't find an URL in the logs at this point (edited to alter my API key and zip), even though it was there earlier, which would be very useful.
     

    Attached Files:

    Last edited: Nov 19, 2018
  5. lajan

    lajan New Member

    Joined:
    Nov 17, 2018
    Messages:
    8
    Likes Received:
    0
    Also, how do you alter the base URL once it's been set? I'm getting that duplicate, and I can only seem to change the PATH, but that doesn't do me any good when the parser, because of user input, doesn't set it properly out of the gate. I tried again, and now I'm getting something like:
    airnowapi.org/aq/observation/zipCode/current/aq/observation/zipCode/current/

    "current" shouldn't be in there, and I can't find a way to remove it, plus what about that base can I get to, to change it to "airnowapi.org", instead of "airnowapi.org/aq/observation/zipCode/current"? I cannot get that option anywhere.
     
  6. lajan

    lajan New Member

    Joined:
    Nov 17, 2018
    Messages:
    8
    Likes Received:
    0
    I've redone it, and, ultimately, I still have that parsing error that I shouldn't have, where I ought to be getting the data in proper format, like so:
    Code (Text):
    [{"DateObserved":"2018-11-19 ","HourObserved":18,"LocalTimeZone":"PST","ReportingArea":"NW Coastal LA","StateCode":"CA","Latitude":34.0505,"Longitude":-118.4566,"ParameterName":"O3","AQI":39,"Category":{"Number":1,"Name":"Good"}},{"DateObserved":"2018-11-19 ","HourObserved":18,"LocalTimeZone":"PST","ReportingArea":"NW Coastal LA","StateCode":"CA","Latitude":34.0505,"Longitude":-118.4566,"ParameterName":"PM2.5","AQI":75,"Category":{"Number":2,"Name":"Moderate"}}]
    Here's the API file, exported, in text, because I couldn't upload it here:
    Code (Text):
    {"auth":{"authKeyInstructions":"Sign up at air airnowapi.org","authType":"NoAuthentication","removeSensitiveInfo":false},"baseUrl":"/aq/forecast/zipCode/","documentationUrl":"airnowapi.org/forecastsbyzip/docs","endpoints":[{"overrideBasePath":"https://airnowapi.org/","parameters":[{"defaultValue":"0","inputType":"text","options":[],"order":"4","parameterType":"Path","shouldBeConfigurable":true,"description":"If no station inside zip, find one within this range, in mi.","id":"distance","name":"Ranged Report"},{"defaultValue":"application/json","inputType":"text","options":[],"order":"3","parameterType":"Path","shouldBeConfigurable":false,"description":"JSON only","id":"format","name":"Format in JSON"},{"inputType":"text","options":[],"order":"2","parameterType":"Path","shouldBeConfigurable":true,"description":"yyyy-mm-dd If left out, current forecast, otherwise get historic values","id":"date","name":"Date"},{"inputType":"text","options":[],"order":"5","parameterType":"Path","shouldBeConfigurable":true,"description":"Your API key","id":"API_KEY","name":"API Key"},{"inputType":"text","options":[],"order":"1","parameterType":"Path","shouldBeConfigurable":true,"description":"Five digit zip code","id":"zipCode","name":"Zip"}],"path":"aq/forecast/zipCode/","requestType":"GET","result":{"fields":[{"getByDefault":false,"isArray":false,"jsonPath":"Latitude","resultFieldType":"body","urlDecode":false,"description":"GPS latitude coordinate","id":"latitude","name":"Latitude"},{"getByDefault":false,"isArray":false,"resultFieldType":"body","urlDecode":false,"description":"GPS longitude coordinate","id":"longditude","name":"Longditude"},{"getByDefault":false,"isArray":false,"jsonPath":"ParameterName","resultFieldType":"body","urlDecode":false,"description":"either ozone or PM25","id":"aqiparametertype","name":"AQI Observation Type"},{"getByDefault":true,"isArray":true,"jsonPath":"Category","resultFieldType":"body","urlDecode":false,"description":"how bad is the air quality in the index?","id":"aqicategory","name":"AQI Category"},{"getByDefault":true,"isArray":false,"jsonPath":"AQI","resultFieldType":"body","urlDecode":false,"description":"either ozone or PM25 measurement value","id":"aqi","name":"AQI Value"},{"getByDefault":true,"isArray":false,"jsonPath":"DateObserved","resultFieldType":"body","urlDecode":false,"description":"The date on which the measurement was made","id":"dateobserved","name":"Date Observed"},{"getByDefault":true,"isArray":false,"jsonPath":"HourObserved","resultFieldType":"body","urlDecode":false,"description":"At what hour was the the measurement observed?","id":"timehoursin24h","name":"Hour Measurement Taken"},{"getByDefault":false,"isArray":false,"jsonPath":"LocalTimeZone","resultFieldType":"body","urlDecode":false,"description":"what time zone your zip is located in","id":"localtimezone","name":"Local Time Zone"},{"getByDefault":false,"isArray":false,"jsonPath":"ReportingArea","resultFieldType":"body","urlDecode":false,"description":"Region the AQI measurements were made in","id":"aqireportingarea","name":"AQI Reporting Area"},{"getByDefault":false,"isArray":false,"resultFieldType":"body","urlDecode":false,"description":"Which state the reporting area belongs to","id":"aqistatecode","name":"AQI State Code"}]},"simpleJson":true,"tested":false,"id":"zipcode","name":"PM25 levels"}],"imageUrl":"https://lh3.ggpht.com/enkRr4OoBK214JGyKrrKGmBJvocWjixwlQo5bEAd-1PNafUd6sldThLbIKDtpA_Voio\u003ds360","lastUpdate":0,"needsChromeCustomTabForAuth":false,"outputType":"json","worksWithNoAuth":false,"description":"Get PM25 measurements by zip code","id":"/aq/forecast/zipCode/","name":"EPA AirNow Current PM25 by Zip"}
    What can be done to get this functioning?
     
  7. lajan

    lajan New Member

    Joined:
    Nov 17, 2018
    Messages:
    8
    Likes Received:
    0
    I know this is really basic, but I'm looking at the AutoWeb log, and it says it is doing only this:
    Code (Text):
    Calling GET: https://airnowapi.org/aq/forecast/zipCode/
    There are no arguments being passed, and so I get a request not authenticated reply. I put the arguments in here to do the testing, and nothing is getting passed.

    To clarify: Tasker says it is passing arguments, and AutoWeb says that it is not.

    20-11-2018 MyPM: 16.43.34#MyPM: getReceiverInfo: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.joaomgcd.autoweb/com.joaomgcd.autoweb.broadcastreceiver.IntentServiceFire}

    Code (Text):
    20-11-2018 E: 16.43.34#E: q1: id: 38 n: EPA AirNow eid: 2 gid: 1 p: 7 a: 0 qt: 0
        A1: AutoWeb Web Service [ Configuration:API: EPA AirNow PM25 JSON
    API Action: PM25 AQI
    Contains All: true
    Zip Code: 90210
    Monitoring station range: 0
    API Key: {mykey} Timeout (Seconds):120 Continue Task After Error:On ]

    20-11-2018 : 16.43.34#:     eventExt (Bundle)
    20-11-2018 E: 16.43.34#E: check work thread, timeToLeave: false
    20-11-2018 : 16.43.34#:         vname / %TRUN (java.lang.String)
    20-11-2018 E: 16.43.34#E: child accepted, exe ID 2
    20-11-2018 E: 16.43.34#E: remove finished task from q: EPA AirNow
    20-11-2018 M: 16.43.34.436#M: checkMatchStates: handleChanges: true handle:
    20-11-2018 M: 16.43.34#M: occurred event count: 1
    20-11-2018 M: 16.43.34#M: handleSystemEvent: no profiles
    20-11-2018 M: 16.43.34.436#M: handleStart: finished handling ID 696
    20-11-2018 WakeLockManager: 16.43.34.436#WakeLockManager: release: M: no record
    20-11-2018 WakeLockManager: 16.43.34#WakeLockManager: acquired partial lock for M flags: 1 autorelease: true warn: true
    20-11-2018 WakeLockManager: 16.43.34#WakeLockManager: setClearAlarm: not setting, last set 60ms ago
    20-11-2018 E: 16.43.34#E: execute task: EPA AirNow
    20-11-2018 E: 16.43.34#E: exe: EPA AirNow / AutoWeb Web Service [ Configuration:API: EPA AirNow PM25 JSON
    API Action: PM25 AQI
    Contains All: true
    Zip Code: 90210
    Monitoring station range: 0
    API Key: {mykey} Timeout (Seconds):120 Continue Task After Error:On ]
    20-11-2018 M: 16.43.34.444#M: process inbox, size 0 startID: 697 ecode 9996
    20-11-2018 : 16.43.34#:     eventType / 9996 (java.lang.Integer)
    20-11-2018 : 16.43.34#:     eventAct / net.dinglisch.android.tasker.VSETUM (java.lang.String)
    20-11-2018 : 16.43.34#:     eventExt (Bundle)
    20-11-2018 : 16.43.34#:         vname / %TRUN (java.lang.String)
    20-11-2018 M: 16.43.34.444#M: checkMatchStates: handleChanges: true handle:
    20-11-2018 M: 16.43.34#M: occurred event count: 1
    20-11-2018 M: 16.43.34#M: handleSystemEvent: no profiles
    20-11-2018 M: 16.43.34.444#M: handleStart: finished handling ID 697
    20-11-2018 WakeLockManager: 16.43.34#WakeLockManager: release: M
    20-11-2018 MyPM: 16.43.34#MyPM: getReceiverInfo: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.joaomgcd.autoweb/com.joaomgcd.autoweb.broadcastreceiver.IntentServiceFire}
    20-11-2018 : 16.43.34#: android.app.ApplicationPackageManager.getReceiverInfo(ApplicationPackageManager.java:408)
    20-11-2018 : 16.43.34#: net.dinglisch.android.taskerm.co.a(SourceFile:122)
    20-11-2018 : 16.43.34#: net.dinglisch.android.taskerm.co.f(SourceFile:198)
    20-11-2018 : 16.43.34#: net.dinglisch.android.taskerm.df.a(SourceFile:365)
    20-11-2018 : 16.43.34#: net.dinglisch.android.taskerm.ExecuteService.a(SourceFile:7348)
    20-11-2018 : 16.43.34#: net.dinglisch.android.taskerm.ExecuteService.a(SourceFile:4890)
    20-11-2018 ActionArgBundle: 16.43.34#ActionArgBundle: key: JoinOutputArray: replace <null> String value with null
    20-11-2018 E: 16.43.34#E: FIRE PLUGIN: AutoWeb Web Service / com.twofortyfouram.locale.intent.action.FIRE_SETTING: 14 bundle keys
    20-11-2018 E: 16.43.34#E: AutoWeb Web Service: plugin comp: com.joaomgcd.autoweb/com.joaomgcd.autoweb.broadcastreceiver.IntentServiceFire
    20-11-2018 E: 16.43.34#E: add wait type Plugin2 time 120
    20-11-2018 E: 16.43.34#E: add wait type Plugin2 done
    20-11-2018 E: 16.43.34#E: handlePluginFinish: taskExeID: 2 result 3
    20-11-2018 E: 16.43.34#E: pending result code
    20-11-2018 E: 16.43.34#E: add wait task
    20-11-2018 E: 16.43.34#E: stillWaiting: test Plugin2
    20-11-2018 E: 16.43.34#E: still waiting for Plugin2: EPA AirNow
    20-11-2018 E: 16.43.34#E: nothing chosen, check exit
    20-11-2018 E: 16.43.34#E: wait for 1000ms
    20-11-2018 WakeLockManager: 16.43.34#WakeLockManager: setClearAlarm: not setting, last set 389ms ago
    20-11-2018 E: 16.43.34#E: ++++ on start, ID: 2
    20-11-2018 E: 16.43.34#E: handlePluginFinishFromIntent: id 2
    20-11-2018 E: 16.43.34#E: handlePluginFinish: taskExeID: 2 result 764991734
    20-11-2018 E: 16.43.34#E: removeWait: Plugin2
    20-11-2018 Plugin: 16.43.34#Plugin: getReturnedVars: var: %err set: 764991724
    20-11-2018 Plugin: 16.43.34#Plugin: getReturnedVars: var: %errmsg set: Input is not valid JSON data: A JSONArray text must start with '[' at 5 [character 6 line 1]
    20-11-2018 E: 16.43.34#E: failure result code: 764991734 errmsg: Input is not valid JSON data: A JSONArray text must start with '[' at 5 [character 6 line 1]
    20-11-2018 E: 16.43.34#E: onstart done: 2
    20-11-2018 E: 16.43.34#E: wait int
    20-11-2018 E: 16.43.34#E: stillWaiting: test Plugin2
    20-11-2018 E: 16.43.34#E: finished waiting for Plugin2 (task EPA AirNow)
     
    Last edited: Nov 21, 2018
  8. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,477
    Likes Received:
    806
    Hmm, I see all your input parameters are set as "Path"... Maybe they were supposed to be Query so they are appended to the URL?
     
  9. lajan

    lajan New Member

    Joined:
    Nov 17, 2018
    Messages:
    8
    Likes Received:
    0
    Huh. I have messed with that before, but I guess with one of the versions I've done, I left them that way.

    So I checked, and the changes from path to query do not appear to persist, and AutoWeb is crashing, too.
    Attempt to invoke virtual method 'java.lang.String android.preference.EditTextPreference.getText()' on a null object reference

    Attempt to invoke virtual method 'java.lang.String com.joaomgcd.autotools.common.api.Endpoint.getId()' on a null object reference

    Unable to start activity ComponentInfo{com.joaomgcd.autoweb/com.joaomgcd.autoweb.activity.ActivityMain}: java.lang.IllegalArgumentException: Wrong state class -- expecting Preference State
     
    Last edited: Nov 22, 2018
  10. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,477
    Likes Received:
    806
    Oh I see. I think your whole issue is that the dropdown boxes are buggy and not being updated correctly. Let me try and correct that, thanks.
     
  11. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,477
    Likes Received:
    806
    Can you please try this version? How does that work? Do the dropdown settings actually work?
     
  12. lajan

    lajan New Member

    Joined:
    Nov 17, 2018
    Messages:
    8
    Likes Received:
    0
    Not really, but it's hard to tell, because the logs aren't being kept in AutoWeb in this version, and the changes I make in the APIs are still not persisting after I change them, for reasons unknown. I change the option in the input configuration for the parameter of "Input Type" from 'text' to 'options', but when I go to test it out, I am not given any option box, because it still only allows text input. Any options I change to the input parameter configurations, they no longer save, though they did, initially. I uninstalled and reinstalled AutoWeb, to no effect. Those errors no longer appear, but it does not seem that the arguments are being passed.

    No logs, no changes persist.
     
  13. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,477
    Likes Received:
    806
    Thank you :( I'll try figuring out what's going on... It all works on my side!
     
: api, api creation

Share This Page