Graphql mutation via curl with variables. Content-Type application/json or /graphql?

Hello,

I’m having troubles to declare variables in graphql and send them via curl. On this forum I found this post, but it wasn’t closed and still doesn’t solve my problem

https://community.shopify.com/post/987521

Whenever I use the Content-Type defined as application/json instead of application/graphql, Shopify sends me back the error Bad Request

For example with this curl

curl -X POST \
https://my-site.myshopify.com/admin/api/2022-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: my-token' \
-d '{
 "query": "mutation productUpdate($input: ProductInput!) {
  productUpdate(input: $input) {
    product {
      id
    }
    userErrors {
      field
      message
    }
  }
}",
"variables":{
  "input": 
    {
      "id": "gid://shopify/Product/{product_id}",
      "title": "New title",
      "descriptionHtml": "

Update from GraphQL Admin API

"
    }
  }
}'

I get back the same message Bad Request also it I try the curl on the Shopify Docs here https://shopify.dev/api/admin-graphql/2022-04/mutations/productUpdate#examples-Update_a_product_s_title_and_return_the_product_ID

Instead, if I use the the Content-Type as application/graphql, I get the same problem of the post I linked here above, something like

{"errors":[{"message":"Parse error on \"query\" (STRING) at [3, 5]","locations":[{"line":2,"column":2}]}]}

Thank you for any input!

Looks like it only works if the query part does not contain newlines.

In the API documentation are also all examples without newlines in the query part.

curl -X POST \
https://my-site.myshopify.com/admin/api/2022-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: my-token' \
-d '{
"query": "mutation productUpdate($input: ProductInput!) { productUpdate(input: $input) { product { id } userErrors { field message } } }",
"variables":{
  "input": 
    {
      "id": "gid://shopify/Product/{product_id}",
      "title": "New title",
      "descriptionHtml": "

Update from GraphQL Admin API

"
    }
  }
}'

Thanks a lot!