iNaturalist API add_photo_to_observation failing

Platform: NA

App version number, if a mobile app issue: NA

Browser, if a website issue: NA

URLs (aka web addresses) of any relevant observations or pages: NA

Screenshots of what you are seeing: NA

Description of problem:

I am experiencing consistent failures when uploading photos to observations via the iNaturalist API using pyinaturalist. The observation is created successfully, but all attempts to attach photos fail with the following error:

UPLOAD ERROR: Expecting value: line 1 column 1 (char 0)

It has always worked up to now, I presume it was disabled for the City Nature Challenge?

Is this the case and when might it be re-enabled?

Thanks, Alex


…

Steps to reproduce:

  • Authenticate using valid iNaturalist API credentials
  • Create observation via API
  • Attempt to attach one or more photos using add_photo_to_observation
  • Observe failure during response parsing

Mentioning @jcook since they work on pyinaturalist.

unlikely. iNat staff don’t work on pyinaturalist. that is a third-party project. you may want to raise your concerns over on the pyinaturalist github repo: https://github.com/pyinat/pyinaturalist/issues.

That looks likely to be an issue with pyinaturalist, not the API. I’m not able to reproduce this myself, though. Can you show me a complete code example of how you’re using it, and the full traceback?

Hi all, thanks for the responses. Jordan, please send me your email so I can send the code example. Here is the traceback:

C:\Users\Alex\Desktop\iNat\API>python iNat_bulk_uploader_2026-05-06.py
Create observation response: [{‘id’: 358817890, ‘observed_on’: ‘2026-03-12’, ‘description’: ‘Bat recorded near cave’, ‘latitude’: ‘-25.7461’, ‘longitude’: ‘28.1881’, ‘map_scale’: None, ‘timeframe’: None, ‘species_guess’: ‘Myotis tricolor’, ‘user_id’: 129251, ‘taxon_id’: 40279, ‘created_at’: ‘2026-05-06T06:07:09.519+02:00’, ‘updated_at’: ‘2026-05-06T06:07:09.519+02:00’, ‘place_guess’: ‘Pretoria’, ‘id_please’: False, ‘observed_on_string’: ‘2026-03-12 18:22:00’, ‘iconic_taxon_id’: 40151, ‘num_identification_agreements’: 0, ‘num_identification_disagreements’: 0, ‘time_observed_at’: ‘2026-03-12T18:22:00.000+02:00’, ‘time_zone’: ‘Pretoria’, ‘location_is_exact’: False, ‘delta’: False, ‘positional_accuracy’: 10, ‘private_latitude’: None, ‘private_longitude’: None, ‘geoprivacy’: None, ‘quality_grade’: ‘casual’, ‘positioning_method’: None, ‘positioning_device’: None, ‘out_of_range’: None, ‘license’: ‘CC-BY-NC’, ‘uri’: None, ‘observation_photos_count’: 0, ‘comments_count’: 0, ‘zic_time_zone’: ‘Africa/Johannesburg’, ‘oauth_application_id’: 525, ‘observation_sounds_count’: 0, ‘identifications_count’: 1, ‘captive’: False, ‘community_taxon_id’: None, ‘site_id’: 1, ‘old_uuid’: None, ‘public_positional_accuracy’: 10, ‘mappable’: True, ‘cached_votes_total’: 0, ‘last_indexed_at’: None, ‘private_place_guess’: None, ‘uuid’: ‘67b6a564-9648-4f7b-ba4c-cd7b48692baa’, ‘taxon_geoprivacy’: ‘open’, ‘tag_list’: [‘bats’, ‘caves’], ‘user_login’: ‘alexanderr’, ‘iconic_taxon_name’: ‘Mammalia’, ‘project_observations’: , ‘created_at_utc’: ‘2026-05-06T04:07:09.519Z’, ‘updated_at_utc’: ‘2026-05-06T04:07:09.519Z’, ‘time_observed_at_utc’: ‘2026-03-12T16:22:00.000Z’, ‘faves_count’: 0, ‘owners_identification_from_vision’: False}]
Created observation ID: 358817890
Uploading: C:\Users\Alex\Desktop\test\test.jpg
Upload error: Expecting value: line 1 column 1 (char 0)
Refreshing token and retrying…
Retry failed: Expecting value: line 1 column 1 (char 0)

That looks like print output from your script, not a traceback from pyinaturalist, so I don’t have enough info yet to help. But in general, that kind of error is due to malformed JSON, which could be a problem either with the input or with the library.

You also likely have an old version of pyinaturalist. In current versions you can pass photos to create_observations() (with a new observation), or upload() (for existing observations).

First try updating to the latest version (v0.21.1), and if that doesn’t fix the issue, attach your code sample with a bug report on GitHub, and I can help troubleshoot more over there.

Sorry about that. Attaching the traceback below. I will try update and if still not working I will submit a bug report on GitHub. Thanks!

Upload error:
JSONDecodeError(‘Expecting value: line 1 column 1 (char 0)’)
Traceback (most recent call last):
File “C:\Users\Alex\Desktop\iNat\API\iNat_bulk_uploader_2026-05-06.py”, line 98, in upload_photos
r = add_photo_to_observation(
File “C:\Program Files\Python39\lib\site-packages\pyinaturalist\rest_api.py”, line 474, in add_photo_to_observation
return response.json()
File “C:\Program Files\Python39\lib\site-packages\requests\models.py”, line 900, in json
return complexjson.loads(self.text, **kwargs)
File “C:\Program Files\Python39\lib\json_init_.py”, line 346, in loads
return _default_decoder.decode(s)
File “C:\Program Files\Python39\lib\json\decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “C:\Program Files\Python39\lib\json\decoder.py”, line 355, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Refreshing token and retrying…
Retry failed: Expecting value: line 1 column 1 (char 0)
Uploading: C:\Users\Alex\Desktop\test\y.jpg

Upload error:
JSONDecodeError(‘Expecting value: line 1 column 1 (char 0)’)
Traceback (most recent call last):
File “C:\Users\Alex\Desktop\iNat\API\iNat_bulk_uploader_2026-05-06.py”, line 98, in upload_photos
r = add_photo_to_observation(
File “C:\Program Files\Python39\lib\site-packages\pyinaturalist\rest_api.py”, line 474, in add_photo_to_observation
return response.json()
File “C:\Program Files\Python39\lib\site-packages\requests\models.py”, line 900, in json
return complexjson.loads(self.text, **kwargs)
File “C:\Program Files\Python39\lib\json_init_.py”, line 346, in loads
return _default_decoder.decode(s)
File “C:\Program Files\Python39\lib\json\decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “C:\Program Files\Python39\lib\json\decoder.py”, line 355, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Refreshing token and retrying…
Retry failed: Expecting value: line 1 column 1 (char 0)

Ok, after updating to latest version and changing to match the updated add_photo_to_observation it is working again. Thanks!