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