I’m not a computer scientist but
I worked with the API
here
https://farmos.discourse.group/t/api-problem-with-curl/317/16
Trying to understand how to enter multiple logs at the same time
I imagined that this could also be the best way to do an export-import
also responding to topics like this
https://farmos.discourse.group/t/download-farm-info/131/2
For exports then it would be enough to export a .json
for example with this command:
curl -X GET --cookie farmOS-cookie.txt -H “X-CSRF-Token: ${TOKEN}” [URL]/log.json
and then import it with curl -X POST
but I’m a little ignorant of the JSON syntax
do you have to build an array?
If the result is like this
{“self”:“https://[URL]/log”,“first”:“https://[URL]/log?page=0”,“last”:“https://[URL]/log?page=0”,
“list”:[
{
“membership”:{“group”:},“inventory”:,“movement”:{“area”:,“geometry”:null},“quantity”:,“id”:“17”,
“name”:“Observation 05/01/2020 - 10:19”,“type”:“farm_observation”
,“uid”:{“uri”:“https://[URL]/user/3”,“id”:“3”,“resource”:“user”},“timestamp”:“1588321152”,“created”:“1588321152”,“changed”:“1588321158”,“done”:“1”,“url”:“https://[URL]/log/17”,“asset”:,“files”:,“images”:,“log_category”:,“log_owner”:[{“uri”:“https://[URL]/user/3”,“id”:“3”,“resource”:“user”}],“notes”:,“flags”:,“geofield”:,“area”:,“equipment”:,“data”:null
},
{
“membership”:{“group”:},“inventory”:,“movement”:{“area”:,“geometry”:null},“quantity”:,“id”:“18”,
“name”:“Observation 05/01/2020 - 10:20”,“type”:“farm_observation”
,“uid”:{“uri”:“https://[URL]/user/3”,“id”:“3”,“resource”:“user”},“timestamp”:“1588321206”,“created”:“1588321206”,“changed”:“1588321210”,“done”:“1”,“url”:“https://[URL]/log/18”,“asset”:,“files”:,“images”:,“log_category”:,“log_owner”:[{“uri”:“https://[URL]/user/3”,“id”:“3”,“resource”:“user”}],“notes”:,“flags”:,“geofield”:,“area”:,"equipment,“data”:null}]
}
it’s actually not enough to import it as it is in a -X POST curl
at least I tried it and it doesn’t work