pyinat / pyinaturalist

Python client for iNaturalist
https://pyinaturalist.readthedocs.io
MIT License
130 stars 17 forks source link

Adding 'Notes' to observations #537

Closed arky closed 7 months ago

arky commented 8 months ago

Am trying to add notes to a new observation (See below for screenshot of inat interface) but there is no keyword such in create_observation. There is description but doesn't seem to do anything.

https://pyinaturalist.readthedocs.io/en/stable/modules/pyinaturalist.v1.observations.html#pyinaturalist.v1.observations.create_observation

image

JWCook commented 8 months ago

Can you show me the code you're running that doesn't correctly create/update the description?

"Notes" in the web interface is the same as the "description" field. I just manually tested this and it appears to be working as expected with both create_observation() and update_observation().

For reference, there is more info here on how fields displayed on inaturalist.org map to API requests/responses.

arky commented 7 months ago

@JWCook here is the code I used. It works well. The issue I faced is that the data structure I was passing was a tuple instead of a string.


  create_observation(
        taxon_id=40268, 
        observed_on_string=time,
        time_zone="Bangkok",
        latitude="10.6122382",
        longitude="104.1774368",
        description="This is a some description.",
        access_token=token,
        #dry_run=True
        )

2023-12-17 18:27:29

[01-15 12:24:49] INFO     Request:                                                                   [session.py](file:///home/arky/.local/lib/python3.10/site-packages/pyinaturalist/session.py):[298](file:///home/arky/.local/lib/python3.10/site-packages/pyinaturalist/session.py#298)
                          POST https://api.inaturalist.org/v1/observations?ignore_photos=1                         
                          User-Agent: python-requests/2.31.0 pyinaturalist/0.19.0                                  
                          Accept-Encoding: gzip, deflate, br                                                       
                          Accept: application/json                                                                 
                          Connection: keep-alive                                                                   
                          Authorization: [REDACTED]                                                                
                          Content-Length: 211                                                                      
                          Content-Type: application/json                                                           
                          {'observation': {'taxon_id': 40268, 'observed_on_string':                                
                          '2023-12-17T18:27:29+07:00', 'time_zone': 'Bangkok', 'description': 'This                
                          is a some description.', 'latitude': '10.6122382', 'longitude':                          
                          '104.1774368'}}                                                                          

[01-15 12:24:51] INFO     Uploading 0 photos and 0 sounds