Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

enviroDIY server not responding to POST

Home Forums Mayfly Data Logger enviroDIY server not responding to POST

This topic contains 5 replies, has 2 voices, and was last updated by  Patrick Lorch 3 months, 1 week ago.

  • Author
    Posts
  • #3214

    Patrick Lorch
    Participant

    I am new to IOT and REST APIs.

    I have been trying for several days to debug a problem with one of the examples from here:

    https://github.com/EnviroDIY/EnviroDIY_Mayfly_Logger

    In the Logging_to_data.EnviroDIY example, I cannot get the server to respond or take my POST.
    I believe the xBee is set up correctly and connecting to the local wireless node. I am able to see the MAC address on Airport Utility, for example.

    Here is an example of my post request and the response from Serial.io (with my tokens replaced with placeholders).

    — Request —
    POST /api/data-stream/ HTTP/1.1
    Host: data.envirodiy.org
    TOKEN: –My token here–
    Cache-Control: no-cache
    Content-Length: 195
    Content-Type: application/json

    {“sampling_feature”: “–my sampling feature UUID here–“, “timestamp”: “2018-02-11T17:
    35:35-05:00”, “–my feature UUID here–“: 24.25, “–my feature UUID here–“: 1.47}

    Request to data.envirodiy.org timed out, no response from server or insufficient signal t
    o send message.


    — Request —

    I am wondering if the server API has changed recently.

    Any suggestions for ways to debug this problem would be appreciated.

    I have tried submitting the post directly to https://data.envirodiy.org/api/data-stream/

    with this response:

    HTTP 400 Bad Request
    Allow: POST, OPTIONS
    Content-Type: application/json
    Vary: Accept

    {
    “detail”: “JSON parse error – No JSON object could be decoded”
    }

  • #3707

    Sara Damiano
    Participant

    I haven’t tried running that particular example in a long time, but I don’t think the POST request format has changed since it was first developed. The server definitely *is* accepting data right now; my online loggers have up-to-date data. I’ll go back to that example and see what happens for me.

  • #3720

    Patrick Lorch
    Participant

    Thanks for your help. I could see that some loggers are posting, but since many are not, it is hard to tell if something has changed. I also know you have been working on the modular sensor code and wondered if that worked differently. I tried to get that working, but had trouble, and thought I should get the simple example working first.

  • #3769

    Sara Damiano
    Participant

    Ok, I hate to admit this, but I’m baffled as to why that example is failing. It really should be working. You do need to change the server IP address (DL) on your XBee to 129.123.41.212 because the server’s IP address has changed. Other than that, everything looks great to me… but the server isn’t responding to the request.

    So, in the meantime, don’t use that example to try to send data to the EnviroDIY portal. Instead, use the EnviroDIY logger library in the ModularSensors library. There are a lot of sensors that the library already supports and we’d love your contributions if you want to add more.

    To use ModularSensors, you’ll need a whole bunch of other libraries installed. You can get them all here: https://github.com/EnviroDIY/Libraries.

    The coding structure has changed enough that you cannot just paste the “code snippet” for your site into the example, but it sounds like you’ve already figured out how to get the GUID’s you need, so you shouldn’t have trouble placing them where they need to go.

    Please let me know if that doesn’t work for you! If you want to try making the post requests by hand, I’d recommend the ‘Postman’ app for google chrome. Make sure you add in the request body; it looks like that’s why your other test to the server failed.

  • #3770

    Patrick Lorch
    Participant

    Thanks Sara. I am betting that just changing the IP address will fix the problem. I was not aware it had changed. I will change that in the README.md and submit a pull request.

    After I discovered the modular library, I had intended to use that for real deployments, but wanted a simple working example to show folks at work first. I will gladly contribute when I can.

    Knowing how to make the post request by hand will be handy for debugging.

    Thanks again for you help.

  • #3939

    Patrick Lorch
    Participant

    Fixing the IP address did the trick. Thanks. I forked to ix in README, but saw you had already done it.

You must be logged in to reply to this topic.