| 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:28 | amonteclicworld[ | Hey jgaehring thanks , using the ajax calls worked |
| 10:29 | amonteclicworld[ | 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:15 | mstenta[m] | @amamonte@clic.world the native app only creates logs currently |
| 12:15 | mstenta[m] | But assets are very similar |
| 12:16 | mstenta[m] | `/farm_asset.json` is the endpoint |
| 12:16 | mstenta[m] | And you can use that to study what an asset structure looks like |
| 12:16 | amonteclicworld[ | Thanks mstenta |
| 12:17 | mstenta[m] | The only required fields are name and type for most assets |
| 12:17 | mstenta[m] | If I remember correctly |
| 12:17 | amonteclicworld[ | 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:17 | amonteclicworld[ | is used to create a log |
| 12:18 | amonteclicworld[ | so my issue is if we run the api , we are only able to read |
| 12:18 | amonteclicworld[ | but cant create despite sending the fields |
| 12:18 | mstenta[m] | Oh you're right, the endpoint doesn't need the .json when you are posting |
| 12:19 | amonteclicworld[ | and when i use only "log" instead of "log.json" , it says page not found |
| 12:19 | mstenta[m] | What does your json look like? |
| 12:19 | mstenta[m] | Oh so you aren't able to post logs either? |
| 12:20 | amonteclicworld[ | yah logs either, nothing is posted |
| 12:20 | amonteclicworld[ | maybe am failing to send the token, that maybe the issue i think |
| 12:20 | mstenta[m] | I'm not in front of my computer at the moment, but can help more later |
| 12:21 | mstenta[m] | If you don't provide a token you will get a 403 |
| 12:22 | mstenta[m] | Are you using curl commands? Or trying to use code from the JS app? |
| 12:22 | amonteclicworld[ | 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:23 | amonteclicworld[ | > Are you using curl commands? Or trying to use code from the JS app? |
| 12:23 | amonteclicworld[ | Am using postman requests |
| 12:23 | mstenta[m] | Oh ok |
| 12:24 | mstenta[m] | I've never used that myself |
| 12:25 | mstenta[m] | Are you sure it is doing all the things that the example curl command is? |
| 12:25 | mstenta[m] | POST |
| 12:25 | mstenta[m] | Include session cookie |
| 12:25 | mstenta[m] | Include XSRF token |
| 12:25 | mstenta[m] | Set the content type to JSON |
| 12:25 | * | uploaded an image: postman.png (54KB) < matrix.org/_matrix/media/v1/download/mat > |
| 12:25 | mstenta[m] | And include a proper JSON packet? |
| 12:26 | amonteclicworld[ | <mstenta[m] "Include XSRF token"> this is what am trying to figure out |
| 12:26 | mstenta[m] | Ok |
| 12:26 | mstenta[m] | I'm on my phone so can't really see the screenshot |
| 12:26 | amonteclicworld[ | let me reformat everything to see ifit works,especially the cookie |
| 12:27 | mstenta[m] | Ok the body should not be form data |
| 12:28 | mstenta[m] | Ok |
| 12:28 | mstenta[m] | This looks like a GET request not a POST? |
| 12:30 | amonteclicworld[ | yes |
| 12:30 | amonteclicworld[ | POST requests return the actual HTML |
| 12:31 | mstenta[m] | That could happen for a few reasons |
| 12:31 | mstenta[m] | If you don't have the content type set to json |
| 12:31 | mstenta[m] | Or if you are posting to the wrong url |
| 12:31 | mstenta[m] | Or not authenticated |
| 12:34 | amonteclicworld[ | 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:34 | mstenta[m] | Data should be raw |
| 12:35 | mstenta[m] | Not x-www-form-urlencoded |
| 12:35 | amonteclicworld[ | alright, let me change that |
| 12:35 | mstenta[m] | That's only for initial login |
| 12:36 | mstenta[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:36 | mstenta[m] | But after that it's all API requests, not form submissions |
| 12:36 | mstenta[m] | If that makes sense |
| 12:37 | mstenta[m] | In the future we'll switch to using oauth instead of user login form probably |
| 12:38 | amonteclicworld[ | In the future we'll switch to using oauth instead of user login form probably |
| 12:38 | amonteclicworld[ | ohh that would be better |
| 12:38 | amonteclicworld[ | yes you were right, it has now added successfully |
| 12:38 | mstenta[m] | Hooray! |
| 12:38 | mstenta[m] | :-) |
| 12:39 | amonteclicworld[ | to the low |
| 12:39 | amonteclicworld[ | *log |
| 12:39 | amonteclicworld[ | after changing to raw data |
| 12:39 | mstenta[m] | For assets, post to `/farm_asset` |
| 12:40 | * | farmBOT has joined |
| 12:40 | amonteclicworld[ | So maybe finally, is it possible to create the account via the API |
| 12:46 | amonteclicworld[ | "/farm_asset" is working well, we are able to add assets and logs mstenta |
| 13:39 | mstenta[m] | amonte@clic.world: Great! |
| 13:50 | * | JustTB has quit (Read error: Connection reset by peer) |
| 13:53 | amonteclicworld[ | > So maybe finally, is it possible to create the account via the API |
| 13:53 | amonteclicworld[ | but is this possible mstenta |
| 13:54 | germarsh[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:00 | mstenta[m] | amonte@clic.world: Oh I misunderstood that... what are you asking? |
| 14:00 | mstenta[m] | Are you trying to create a "user account" via the API? |
| 14:01 | mstenta[m] | The user entity endpoint is not currently enabled in farmOS - just logs, assets, and taxonomy terms |
| 14:02 | mstenta[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:02 | mstenta[m] | thought* |
| 14:02 | mstenta[m] | So for now, you can only create users through the UI |
| 14:03 | mstenta[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:52 | amonteclicworld[ | Great thanks |
| 19:51 | mstenta[m] | paul121: jgaehring |
| 19:52 | mstenta[m] | He's working on the native/offline/client JS app |
| 19:52 | mstenta[m] | Along with Alex (who I don't think is in this room currently) |
| 19:52 | mstenta[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 |