API error

API error

Please can someone tell me what I'm doing wrong here?

I have created a "Self Client" app in the API console (the EU one as that's where our accounts are).
I have copied the client ID and client secret. I have then generated a code, for scopes Desk.search.READ , Desk.tickets.READ.

I am then using a simple bash script, with CURL to get the refresh token:
  1. #!/bin/bash

  2. CODE=GENERATEDCODE
  3. CLIENT_ID=1000....
  4. CLIENT_SECRET=3...
  5. curl -X POST https://accounts.zoho.eu/oauth/v2/token?code=$CODE&grant_type=authorization_code&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&redirect_uri=ourserver
However, if I run this and try to save the output to a json file, I always get the response {"error":"invalid_client"}

What is it I'm doing wrong?