Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geolocation cannot be stored when creating a new note via API #3884

Closed
jpmens opened this issue Oct 9, 2020 · 4 comments
Closed

Geolocation cannot be stored when creating a new note via API #3884

jpmens opened this issue Oct 9, 2020 · 4 comments
Labels
api Joplin API bug It's a bug desktop All desktop platforms high High priority issues

Comments

@jpmens
Copy link

jpmens commented Oct 9, 2020

I'm creating a new note using the API and wish to set geolocation information on the note. I specifically use strings for latitude and longitude because that's how the API returns an existing note (see below). Using JSON numbers makes no difference: the result is the same.

Environment

Joplin version: 1.2.6 (prod, darwin)
Platform: macOS
OS specifics: macOS 10.15.6

Steps to reproduce

  1. Run the script
#!/bin/sh

curl http://localhost:41184/notes?token=${token} --data '{
    "parent_folder": "4a5daf15f3cd4353a9e63bcaa74f8930",
    "is_todo": 0,
    "title": "Test001",
    "body": "Check location",
    "author": "jpmens",
    "latitude": "48.8568",
    "longitude": "2.2927",
    "altitude": "0.0000"
}'

I run that small shell script:

{"title":"Test001","body":"Check location","parent_id":"4a5daf15f3cd4353a9e63bcaa74f8930","author":"jpmens","is_todo":0,"markup_language":1,"updated_time":1602246270426,"created_time":1602246270426,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","order":1602246270426,"id":"e4f8f38ca8b94e03b9948a5dd332fb77","user_updated_time":1602246270426,"user_created_time":1602246270426,"type_":1}
  1. check the note is created

The note is created, but when I verify using the (I) button in the UI the Location field is not populated (I can edit it).
All other note attributes I've tested (author, url, etc.) work fine.

  1. export the created note

Exporting a note which I've created in the Joplin UI with Location pasted into the field, and exporting my above test note produce the following diff (the API-created note has "0.0000" for latitude and longitude:

Left (<) file is the one created/edited in the UI, and the right (>) file is the one created via the API

2c2
<   "id": "c56a21040ab44285b44ac1f4c1bce731",
---
>   "id": "e4f8f38ca8b94e03b9948a5dd332fb77",
4,7c4,7
<   "title": "Test000-lat",
<   "body": "edited in Joplin macOS",
<   "created_time": 1602246322518,
<   "updated_time": 1602246357306,
---
>   "title": "Test001",
>   "body": "Check location",
>   "created_time": 1602246270426,
>   "updated_time": 1602246270426,
9,10c9,10
<   "latitude": "48.85682600",
<   "longitude": "2.29271300",
---
>   "latitude": "0.00000000",
>   "longitude": "0.00000000",
12c12
<   "author": "",
---
>   "author": "jpmens",
20,22c20,22
<   "order": 0,
<   "user_created_time": 1602246300000,
<   "user_updated_time": 1602246300000,
---
>   "order": 1602246270426,
>   "user_created_time": 1602246270426,
>   "user_updated_time": 1602246270426,

Describe what you expected to happen

I expected the note to contain latitude and longitude and to see that in the UI, and I expect a GET of the note would provide the fields in its JSON.

Logfile

2020-10-09 14:24:30: "Request: POST /notes?token=<redacted>"
2020-10-09 14:24:30: "Request (1602246270424): Downloading images: 0"
2020-10-09 14:24:30: "Request (1602246270424): Creating resources from paths: 0"
2020-10-09 14:24:30: "Request (1602246270424): Saving note..."
2020-10-09 14:24:30: "Request (1602246270424): Created note e4f8f38ca8b94e03b9948a5dd332fb77"
@jpmens jpmens added the bug It's a bug label Oct 9, 2020
@jpmens
Copy link
Author

jpmens commented Oct 9, 2020

Updating the note via the API sets the desired values, so I would assume the above really is a bug?

#!/bin/sh

id=e4f8f38ca8b94e03b9948a5dd332fb77

curl -XPUT http://localhost:41184/notes/${id}?token=${token} --data '{
    "latitude": "48.8568",
    "longitude": "2.2927"
}'

when I run the PUT I see the latitude and longitude fields in the server's response:

{
  "id": "e4f8f38ca8b94e03b9948a5dd332fb77",
  "parent_id": "4a5daf15f3cd4353a9e63bcaa74f8930",
  "title": "Test001",
  "body": "Check location",
  "created_time": 1602246270426,
  "updated_time": 1602253646979,
  "is_conflict": 0,
  "latitude": "48.85680000",
  "longitude": "2.29270000",
  "altitude": "0.0000",
  "author": "jpmens",
  "source_url": "",
  "is_todo": 0,
  "todo_due": 0,
  "todo_completed": 0,
  "source": "joplin-desktop",
  "source_application": "net.cozic.joplin-desktop",
  "application_data": "",
  "order": 1602246270426,
  "user_created_time": 1602246270426,
  "user_updated_time": 1602253646979,
  "encryption_cipher_text": "",
  "encryption_applied": 0,
  "markup_language": 1,
  "is_shared": 0,
  "type_": 1
}

and see there, the UI shows me the location:

rabbit-6974

and finally, when I GET and request all fields:

[
  {
    "id": "e4f8f38ca8b94e03b9948a5dd332fb77",
    "parent_id": "4a5daf15f3cd4353a9e63bcaa74f8930",
    "title": "Test001",
    "body": "Check location",
    "created_time": 1602246270426,
    "updated_time": 1602253646979,
    "is_conflict": 0,
    "latitude": "48.85680000",
    "longitude": "2.29270000",
    "altitude": "0.0000",
    "author": "jpmens",
    "source_url": "",
    "is_todo": 0,
    "todo_due": 0,
    "todo_completed": 0,
    "source": "joplin-desktop",
    "source_application": "net.cozic.joplin-desktop",
    "application_data": "",
    "order": 1602246270426,
    "user_created_time": 1602246270426,
    "user_updated_time": 1602253646979,
    "encryption_cipher_text": "",
    "encryption_applied": 0,
    "markup_language": 1,
    "is_shared": 0,
    "type_": 1
  },

@jpmens
Copy link
Author

jpmens commented Oct 9, 2020

I thought I had the latest version. I've updated the issue to reflect that I've now tested with

Joplin for Desktop

Copyright © 2016-2020 Laurent Cozic
Joplin 1.2.6 (prod, darwin)

Client ID: a7f1b26d9ccd4f7fb1113e45d859ed36
Sync Version: 2
Profile Version: 34
Keychain Supported: Yes

Revision: f5f117c (master)

It behaves identically with respect to this issue: a new note doesn't add the geolocation data, but a subsequent PUT does.

@laurent22
Copy link
Owner

It turns out there's a whitelist of note properties that can be set when creating or updating a note, and geolocation was not in them. I've now added support for this too so it will be in the next version.

@jpmens
Copy link
Author

jpmens commented Nov 6, 2020

Thank you for fixing this! I confirm that Joplin 1.3.18 (prod, darwin) works as I wished it to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Joplin API bug It's a bug desktop All desktop platforms high High priority issues
Projects
None yet
Development

No branches or pull requests

2 participants