#search/metadata albumIds string error

7 messages · Page 1 of 1 (latest)

gloomy obsidian
#

I am building a kind of bridge, that pulls pictures from immich, dithers them and makes them available to an e-ink picture frame.
All of that used to work until the API was changed. Now I am trying to rewrite, to use the POST endpoint "search/metadata".

However, it seems to not work with only a single album. It seems that the array is flattened to a string at some point?

response = requests.post(url + "/api/search/metadata", headers=headers, data={"albumIds":['2b63277d-1154-4521-8b40-7a3469545be5']})

data = response.json()

data
{'message': 'Validation failed', 'errors': [{'expected': 'array', 'code': 'invalid_type', 'path': ['albumIds'], 'message': 'Invalid input: expected array, received string'}]}

latent fiberBOT
#

:wave: Hey @gloomy obsidian,

Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich immich.

References

#

Checklist

I have...

  1. :ballot_box_with_check: verified I'm on the latest release(note that mobile app releases may take some time).
  2. :ballot_box_with_check: read applicable release notes.
  3. :ballot_box_with_check: reviewed the FAQs for known issues.
  4. :ballot_box_with_check: reviewed Github for known issues.
  5. :blue_square: tried accessing Immich via local ip (without a custom reverse proxy).
  6. :blue_square: uploaded the relevant information (see below).
  7. :blue_square: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable

(an item can be marked as "complete" by reacting with the appropriate number)

Information

In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider:

  • Your docker-compose.yml and .env files.
  • Logs from all the containers and their status (see above).
  • All the troubleshooting steps you've tried so far.
  • Any recent changes you've made to Immich or your system.
  • Details about your system (both software/OS and hardware).
  • Details about your storage (filesystems, type of disks, output of commands like fdisk -l and df -h).
  • The version of the Immich server, mobile app, and other relevant pieces.
  • Any other information that you think might be relevant.

Please paste files and logs with proper code formatting, and especially avoid blurry screenshots.
Without the right information we can't work out what the problem is. Help us help you ;)

If this ticket can be closed you can use the /close command, and re-open it later if needed.

flint shell
#

post the actual json that gets sent to the server

lyric dune
#

Depending on the sdk it's also possible you need to explicitly specify the Content-Type

flint shell
#

if you omit that it doesn't actually error

#

it just doesn't filter :P

gloomy obsidian
gloomy obsidian
#

This is what I can see using docker log, when setting log level to VERBOSE:

[Nest] 25 - 09/18/2026, 8:50:30 AM DEBUG [Api:LoggingInterceptor~hp6eiiwl] POST /api/search/metadata 200 0.47ms 192.168.1.12
[Nest] 25 - 09/18/2026, 8:50:30 AM VERBOSE [Api:LoggingInterceptor~hp6eiiwl] {"albumIds":"2b63277d-1154-4521-8b40-7a3469545be5"}
[Nest] 25 - 09/18/2026, 8:50:30 AM DEBUG [Api:GlobalExceptionFilter~hp6eiiwl] HttpException(400): {"statusCode":400,"message":"Validation failed","errors":[{"expected":"array","code":"invalid_type","path":["albumIds"],"message":"Invalid input: expected array, received string"}]}

#

Looks like the array is flattened to a string at some point

#

looks like the requests library does it:

response.request.body
'albumIds=2b63277d-1154-4521-8b40-7a3469545be5'

#

trying to force an array by adding the same UUID twice:

#

response = requests.post(url + "/api/search/metadata", headers=headers, data={'albumIds':['2b63277d-1154-4521-8b40-7a3469545be5','2b63277d-1154
-4521-8b40-7a3469545be5']})

response.request.body
'albumIds=2b63277d-1154-4521-8b40-7a3469545be5&albumIds=2b63277d-1154-4521-8b40-7a3469545be5'

data = response.json()

data
{'albums': {'total': 0, 'count': 0, 'items': [], 'facets': []}, 'assets': {'total': 0, 'count': 0, 'items': [], 'facets': [], 'nextPage': None, 'nextCursor': None}}

#

That works, but doesn't give any results. There should be pictures in that Album. I guess immich is using "and" logic between more than one albumIds

gloomy obsidian
lyric dune
gloomy obsidian
#

headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'x-api-key': apikey
}

response = requests.post(url + "/api/search/metadata", headers=headers, data={'albumIds':['2b63277d-1154-4521-8b40-7a3469545be5']})

data = response.json()

data
{'message': 'Unexpected token 'a', "albumIds=2"... is not valid JSON'}

#

I think it is related to how pythons requests library handles things

#

it works now. Thank you!

headers = {
... 'Accept': 'application/json',
... 'x-api-key': 'xxxxxx'
... }

response = requests.post(url + "/api/search/metadata", headers=headers, json={'albumIds':['2b63277d-1154-4521-8b40-7a3469545be5']})

data = response.json()

data
{'albums': {'total': 0, 'count': 0, 'items': [], 'facets': []}, 'assets': {'total': 29, 'count': 29, 'items': [{'

#

use the json parameter instead of data in the post function 🙂