LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

POST method on nested path (JSON)

Hello,

 

I'm having problem POSTing data when the PATH is nested from the main path.The structure of the JSON file is like this:

{
   "dev1": [ ],
   "dev2": [ ],
   "sensor": [
      {
         "sen1": [ ],
         "sen2": [ ]
      }
    ],
"configuration": [
     {
         "dev1": { },
         "dev2": { },
         "sen1": { },
         "sen2": { }
     }
  ]
}

 

Posting data from device1 and device2 (dev1 & dev2) works fine. However, when I try posting data from sensor 1, it fails. I don't know if the problem is the path.

post sensor1.png

 

POST error.gif

 

I'm using LabVIEW 2020 with JKI tools - HTTP REST Client.

 

Thanks in advance.

0 Kudos
Message 1 of 4
(1,116 Views)

Haven't worked with any of this, but "sensor" is an array of "clusters" ({sen1,sen2}).

So either POST both sen1 and sen2 in a cluster togehter to "sensors", change your definition (remove brackets in sensor definition) or try something like sensors/1/sen1, although I'm not sure the latter will work.

 

0 Kudos
Message 2 of 4
(1,085 Views)

Hi,

 

did you come to a solution for this?

0 Kudos
Message 3 of 4
(442 Views)

The URL he POSTs to does not exist, the POST code is 404 (not found).

The endpoint "/dev1" exists, but "/sen1" does not.

If I am understanding the JSON Server readme about nested ressources correctly, it should be possible to post to "/sensors/1/sen1"

 

0 Kudos
Message 4 of 4
(432 Views)