Home Forum Software POST API for KIT1

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #6654
    Julius Ski
    Participant

    Hello guys, I am currently working on some open source project on metering radiation with ESP8266 (will be posted in git later), would like to include data post to uRAD database, but could not find any API how to perform HTTP POST queries. Tried such scenario:
    perform POST to data.uradmonitor.com with such contents:

    POST /api/v1/upload/exp/ HTTP/1.1
    Host: data.uradmonitor.com
    X-User-id: 4085
    X-User-hash: <hash_here>
    X-Device-id: 0
    User-Agent: uRADMonitor/1.1
    Accept: */*
    Host: data.uradmonitor.com
    Content-Length: 44
    
    01/120/0E/106/0F/123/0B/15/0C/399/0D/54/10/1

    got response with new deviceID: 13000206 which was stored in flash, and further queries looks like this:

    POST /api/v1/upload/exp/ HTTP/1.1
    Host: data.uradmonitor.com
    X-User-id: 4085
    X-User-hash: <hash_here>
    X-Device-id: 13000206
    User-Agent: uRADMonitor/1.1
    Accept: */*
    Host: data.uradmonitor.com
    Content-Length: 44
    
    01/180/0E/106/0F/123/0B/15/0C/399/0D/54/10/1

    ,however no data is being parsed by the server: https://www.uradmonitor.com/tools/dashboard-04/?open=13000206

    What am I doing wrong ? If project owner does not respont, could someone with working KIT1 capture the data with headers sent to server and share it here ?

    Thanks.

    #6661
    uRADMonitor
    Keymaster

    hi Julius! Would love to see your ESP design. Post some pics! I wanted to do something similar but I didn’t have the chance yet. However the SMOGGIE is using it:

    Products

    Looking over your ID, I see some data has been pushed:
    https://www.uradmonitor.com/tools/dashboard-04/?open=13000206

    So I assume you were successful. The 0E (hardware ID) and OF (software ID) seem not to be received.

    What response are you getting on your calls?

    #6663
    Julius Ski
    Participant

    I do get json:
    {
    “success” : “ok”
    }

    Seems like the server ignores/incorrectly accepts the body part of the POST, maybe because of headers, not sure how to debug it.

    Photo (dev version) 🙂 https://gyazo.com/5c74f419f27f7c08d0b5894c3366822f

    #6664
    Julius Ski
    Participant

    I did even reconstruct the order of headers to match the KIT1 source, in intense if your server is reading headers incrementally:

    POST /api/v1/upload/exp/ HTTP/1.1
    Host: data.uradmonitor.com
    User-Agent: uRADMonitor/1.1
    X-User-id: 4085
    X-User-hash: <hash_here>
    X-Device-id: 13000206
    Accept: */*
    Content-Length: 39
    Content-Type: application/x-www-form-urlencoded
    
    01/6/0E/106/0F/123/0B/0/0C/0/0D/54/10/1
    
    200
    {"success":"ok"}
    
    POST /api/v1/upload/exp/ HTTP/1.1
    Host: data.uradmonitor.com
    User-Agent: uRADMonitor/1.1
    X-User-id: 4085
    X-User-hash: <hash_here>
    X-Device-id: 13000206
    Accept: */*
    Content-Length: 43
    Content-Type: application/x-www-form-urlencoded
    
    01/60/0E/106/0F/123/0B/24/0C/399/0D/54/10/1
    
    200
    {"success":"ok"}
    
    POST /api/v1/upload/exp/ HTTP/1.1
    Host: data.uradmonitor.com
    User-Agent: uRADMonitor/1.1
    X-User-id: 4085
    X-User-hash: <hash_here>
    X-Device-id: 13000206
    Accept: */*
    Content-Length: 44
    Content-Type: application/x-www-form-urlencoded
    
    01/120/0E/106/0F/123/0B/31/0C/400/0D/54/10/1
    
    200
    {"success":"ok"}
    
    POST /api/v1/upload/exp/ HTTP/1.1
    Host: data.uradmonitor.com
    User-Agent: uRADMonitor/1.1
    X-User-id: 4085
    X-User-hash: <hash_here>
    X-Device-id: 13000206
    Accept: */*
    Content-Length: 44
    Content-Type: application/x-www-form-urlencoded
    
    01/180/0E/106/0F/123/0B/24/0C/400/0D/54/10/1
    
    200
    {"success":"ok"}
    
    POST /api/v1/upload/exp/ HTTP/1.1
    Host: data.uradmonitor.com
    User-Agent: uRADMonitor/1.1
    X-User-id: 4085
    X-User-hash: <hash_here>
    X-Device-id: 13000206
    Accept: */*
    Content-Length: 44
    Content-Type: application/x-www-form-urlencoded
    
    01/241/0E/106/0F/123/0B/19/0C/400/0D/54/10/1
    200
    {"success":"ok"}
    

    Still, no data passed. I would debug it myself, if I would have ENC eth adapter, just need to print to UART message before sending.

    #6666
    uRADMonitor
    Keymaster

    Please leave it running, I’m checking it on the server side.

    #6667
    uRADMonitor
    Keymaster

    hi Julius,

    The problem is minor:

    You need to pass the data part as part of the script url, and have 0 bytes content, like this:

    1562587805> 
    1562587805, 79.208.244.110, upload/exp/01/141780/0E/105/0F/122/0B/23/0C/384/0D/595/02/31.00/03/100451/04/25, 
    Host: data.uradmonitor.com
    User-Agent: uRADMonitor/1.1
    X-User-id: 452
    X-User-hash: ***
    X-Device-id: 130001FF
    Accept: */*
    Content-Length: 0
    Content-Type: application/x-www-form-urlencoded

    Instead you are sending the “EXP data” part , as the HTTP Post body, and the body has non 0 length:

    1562587644> 
    1562587644, 78.56.46.177, upload/exp/, 01/4349/0E/106/0F/123/0B/32/0C/399/0D/54/10/1
    Host: data.uradmonitor.com
    User-Agent: uRADMonitor/1.1
    X-User-id: 4085
    X-User-hash: ***
    X-Device-id: 13000206
    Accept: */*
    Content-Length: 45
    Content-Type: application/x-www-form-urlencoded

    Would you post a few pics with your setup? Ideally a blog post on this would be awesome, on how you made your ESP variant and the software for it. I can update your account for blog access, let me know if you are willing to do it.

    #6668
    Julius Ski
    Participant

    Wow, that’s my bad, traced it badly in the KIT1 source 🙁 didn’t even foreknow that empty body can be sent…

    It’s working now fine, thank you for assistance.

    Setup is not finished yet, but it includes 2x 16bit adc’s for HV and Battery measurements, PID regulated HV voltage, local HTTP server for management. I will now include BME sensor as well. Perhaps I could tell more about the project later when the beta is finished, I will post to GitHub, then I will contact you.

    Thanks again!

    #6669
    uRADMonitor
    Keymaster

    Excellent

    #6670
    Julius Ski
    Participant

    Some updates on GUI while I am waiting for my BME280 sensor, temporarily BMP180 was added (no humidity).

    Also, I have some issues on battery voltage uploads, I tried to post it as 0A/4.20 and 0A/4.20V, but it always shows in a detailed page (https://www.uradmonitor.com/tools/dashboard-04/?open=13000206) as 4.20undefined. How to add measuring units?

    #6671
    Julius Ski
    Participant

    Some video in-action: https://youtu.be/oBJsqtiIqns

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.