Bad request 400 for all API calls to jira software cloud from on-premise app using OAuth

I am developing an on-premise app that should update Jira build and development info in jira issues. I am following the steps from this web page: Integrating Jira Software Cloud with on-premises tools

What I did so far:

  • create OAuth credentials in Jira in Settings > Apps > Oauth credentials
  • got my cloud ID by going to this site: https://.atlassian.net/_edge/tenant_info
  • get an access token by making this call (with the client id and client secret from the Oauth credentials):
  • curl --location 'https://auth.atlassian.com/oauth/token' \
    --header 'Content-Type: application/json' \
    --data '{
        "audience": "api.atlassian.com",
        "grant_type": "client_credentials",
        "client_id": "lDP*****************",
        "client_secret": "ATOA**************************************"
    }'
    

I get the access token successfully with this response:

{
    "access_token": "ey*****.....",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": "manage:jira-data-provider"
}

But when I use a fresh access token in any API call I am getting a error:

400 Bad Request, ERROR: The request could not be satisfied

I get the error when I make this call:

curl --location 'https://api.atlassian.com/jira/deployments/0.1/cloud/0e.....5b/bulk' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ.....' \
--data '{
  "deployments": [
    {
      "deploymentSequenceNumber": 10,
      "updateSequenceNumber": 1,
      "associations": [
        {
          "associationType": "issueIdOrKeys",
          "values": [
            "WIT-40"
          ]
        }
      ],
      "displayName": "v2.0",
      "url": "http://example.com",
      "description": "Updating APIs to v2.0",
      "lastUpdated": "2021-04-02T23:27:25.000Z",
      "state": "successful",
      "pipeline": {
        "id": "api-update",
        "displayName": "API updates",
        "url": "http://example.com/pipeline/api-update"
      },
      "environment": {
        "id": "test",
        "displayName": "Test",
        "type": "test"
      }
    }
  ]
}'

And I get the same error when I call this for a build update:

curl --location 'https://api.atlassian.com/jira/builds/0.1/cloud/0e79.........5b/bulk' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ey......' \
--data '{
    "builds": [
        {
            "schemaVersion": "1.0",
            "pipelineId": "my-build-plan",
            "buildNumber": 16,
            "updateSequenceNumber": 1523494301448,
            "displayName": "My Project build #16",
            "description": "My Project build #16: Failed",
            "label": "test",
            "url": "https://example.com",
            "state": "failed",
            "lastUpdated": "2018-01-20T23:27:25.000Z",
            "associations": [
                {
                    "associationType": "issueIdOrKeys",
                    "values": [
                        "WIT-62"
                    ]
                }
            ]
        }
    ]
}'

Because the error is so generic, i can’t tell what’s wrong.

What is wrong with these requests or the setup?