Curl API Error 401 Unauthorized

Trying to use the api to scan my library so I can make a script on a cron job or for Whisparr to run after a download

My command thus far:

curl -v POST -H “ApiKey: ” -H “Content-Type: application/json” --data ‘mutation { metadataScan(input: {paths:[“/data”] rescan:false scanGenerateCovers:true scanGeneratePreviews:true scanGenerateImagePreviews:true scanGenerateSprites:true scanGeneratePhashes:true scanGenerateThumbnails:true scanGenerateClipPreviews:true})}’ 192.168.1.xx:9999/graphql

I get an error: HTTP 401 - unauthorized (this is why I am using Verbose)
Screenshot below

I can access the api with Stasharr no issue
I tried generating a new api key, no change
Nothing in the stashapp logs
I have tried running it from shell on my TrueNAS, which hosts all my apps
Stashapp v0.30.1 (latest)

Not sure what I am doing wrong or how to fix it?

that’s not valid json. it has to be wrapped in --data '"query": "{ mutation {} }"'

Thank you, I have fixed that issue

I should have mentioned I basically have no knowledge of json or curl or such
I was putting the api key in “ApiKey: <actual_key>” when it’s meant to be “ApiKey: actual_key”
Also, curly quotes. Not sure if that did anything but it all works now

Thank you

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.