< 112018-12-12⋎13 >

farmOS (farmos.org) is a free and open source, web-based farm management system. User guide: farmos.org/guide/ - Feature requests and bug reports: github.com/farmOS/farmOS/issuesSet by ChanServ on 2018-08-16 at 14:32
01:29*JustTB has joined
03:51*JustTB has quit (Ping timeout: 246 seconds)
09:13*Morgs_John has joined
09:13*Morgs_John has quit (Client Quit)
09:34*JustTB has joined
10:28amonteclicworld[Hey jgaehring thanks , using the ajax calls worked
10:29amonteclicworld[now i wanted to know how we can get to create assets because it seems i cant find the calls in github.com/farmOS/farmOS-native
12:15mstenta[m]@amamonte@clic.world the native app only creates logs currently
12:15mstenta[m]But assets are very similar
12:16mstenta[m]`/farm_asset.json` is the endpoint
12:16mstenta[m]And you can use that to study what an asset structure looks like
12:16amonteclicworld[Thanks mstenta
12:17mstenta[m]The only required fields are name and type for most assets
12:17mstenta[m]If I remember correctly
12:17amonteclicworld[because according to the documentation curl -X POST --cookie farmOS-cookie.txt -H "X-CSRF-Token: ${TOKEN}" -H 'Content-Type: application/json' -d '{"name": "Test observation via REST", "type": "farm_observation", "timestamp": "1526584271"}' [URL]/log
12:17amonteclicworld[is used to create a log
12:18amonteclicworld[so my issue is if we run the api , we are only able to read
12:18amonteclicworld[but cant create despite sending the fields
12:18mstenta[m]Oh you're right, the endpoint doesn't need the .json when you are posting
12:19amonteclicworld[and when i use only "log" instead of "log.json" , it says page not found
12:19mstenta[m]What does your json look like?
12:19mstenta[m]Oh so you aren't able to post logs either?
12:20amonteclicworld[yah logs either, nothing is posted
12:20amonteclicworld[maybe am failing to send the token, that maybe the issue i think
12:20mstenta[m]I'm not in front of my computer at the moment, but can help more later
12:21mstenta[m]If you don't provide a token you will get a 403
12:22mstenta[m]Are you using curl commands? Or trying to use code from the JS app?
12:22amonteclicworld[and since i was able to login, its no longer 403, so i should be able to create logs and assets but i can only read the logs and Assets
12:23amonteclicworld[> Are you using curl commands? Or trying to use code from the JS app?
12:23amonteclicworld[Am using postman requests
12:23mstenta[m]Oh ok
12:24mstenta[m]I've never used that myself
12:25mstenta[m]Are you sure it is doing all the things that the example curl command is?
12:25mstenta[m]POST
12:25mstenta[m]Include session cookie
12:25mstenta[m]Include XSRF token
12:25mstenta[m]Set the content type to JSON
12:25*uploaded an image: postman.png (54KB) < matrix.org/_matrix/media/v1/download/mat >
12:25mstenta[m]And include a proper JSON packet?
12:26amonteclicworld[<mstenta[m] "Include XSRF token"> this is what am trying to figure out
12:26mstenta[m]Ok
12:26mstenta[m]I'm on my phone so can't really see the screenshot
12:26amonteclicworld[let me reformat everything to see ifit works,especially the cookie
12:27mstenta[m]Ok the body should not be form data
12:28mstenta[m]Ok
12:28mstenta[m]This looks like a GET request not a POST?
12:30amonteclicworld[yes
12:30amonteclicworld[POST requests return the actual HTML
12:31mstenta[m]That could happen for a few reasons
12:31mstenta[m]If you don't have the content type set to json
12:31mstenta[m]Or if you are posting to the wrong url
12:31mstenta[m]Or not authenticated
12:34amonteclicworld[The cookie is present with the Token set, the URL is set without ".json", and the content type is set to "json" and finally the data is sent as x-www-form-urlencoded
12:34mstenta[m]Data should be raw
12:35mstenta[m]Not x-www-form-urlencoded
12:35amonteclicworld[alright, let me change that
12:35mstenta[m]That's only for initial login
12:36mstenta[m]The reason you need that for initial login is because it's just using the normal Drupal login form to authenticate and get a session cookie
12:36mstenta[m]But after that it's all API requests, not form submissions
12:36mstenta[m]If that makes sense
12:37mstenta[m]In the future we'll switch to using oauth instead of user login form probably
12:38amonteclicworld[In the future we'll switch to using oauth instead of user login form probably
12:38amonteclicworld[ohh that would be better
12:38amonteclicworld[yes you were right, it has now added successfully
12:38mstenta[m]Hooray!
12:38mstenta[m]:-)
12:39amonteclicworld[to the low
12:39amonteclicworld[*log
12:39amonteclicworld[after changing to raw data
12:39mstenta[m]For assets, post to `/farm_asset`
12:40*farmBOT has joined
12:40amonteclicworld[So maybe finally, is it possible to create the account via the API
12:46amonteclicworld["/farm_asset" is working well, we are able to add assets and logs mstenta
13:39mstenta[m]amonte@clic.world: Great!
13:50*JustTB has quit (Read error: Connection reset by peer)
13:53amonteclicworld[> So maybe finally, is it possible to create the account via the API
13:53amonteclicworld[but is this possible mstenta
13:54germarsh[m]<troym541[m] "germarsh: Thanks, we try. lol B"> It is probably much wetter than some places represented here! It is beautiful though. We have been here only a year. We were in The Brecon Beacons before that. Much colder climate!
14:00mstenta[m]amonte@clic.world: Oh I misunderstood that... what are you asking?
14:00mstenta[m]Are you trying to create a "user account" via the API?
14:01mstenta[m]The user entity endpoint is not currently enabled in farmOS - just logs, assets, and taxonomy terms
14:02mstenta[m]There may be some security implications to allowing users to be generated via the API, so I would need to give that some though, especially as it relates to Farmier hosting security
14:02mstenta[m]thought*
14:02mstenta[m]So for now, you can only create users through the UI
14:03mstenta[m]If you want to play around with hosting it yourself, you could enable the user REST endpoint by adding a line to this file (and clearing the Drupal cache): github.com/farmOS/farmOS/blob/7.x-1.x/mo
14:52amonteclicworld[Great thanks
19:51mstenta[m]paul121: jgaehring
19:52mstenta[m]He's working on the native/offline/client JS app
19:52mstenta[m]Along with Alex (who I don't think is in this room currently)
19:52mstenta[m]@alexasbeet is his screenname
22:29*Adam[m]8 has quit (Ping timeout: 250 seconds)
22:29*mrw[m] has quit (Ping timeout: 250 seconds)
22:29*dodgen247[m] has quit (Ping timeout: 250 seconds)
22:29*alexheiss[m] has quit (Ping timeout: 250 seconds)
22:29*donblair[m] has quit (Ping timeout: 250 seconds)
22:30*donblair[m] has joined
22:30*alexheiss[m] has joined
22:30*dodgen247[m] has joined
22:30*mrw[m] has joined
22:30*Adam[m]8 has joined

< 112018-12-12⋏13 >