cancel
Showing results for 
Search instead for 
Did you mean: 

POST method on nested path (JSON)

vicens
Member

POST method on nested path (JSON)

Message contains an image Message contains an attachment

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.

3 REPLIES 3
cordm
Active Participant

Re: POST method on nested path (JSON)

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.

 

Rob_Ventura
Member

Re: POST method on nested path (JSON)

Hi,

 

did you come to a solution for this?

cordm
Active Participant

Re: POST method on nested path (JSON)

Message contains a hyperlink

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"