CURL 变量和解析问题 JSON

CURL variables and problems parsing JSON

我的脚本正在使用 github API:

创建拉取请求

./my-script.sh my-repo my-branch

#!/bin/bash

Repo=
Branch=

cd $Repo
 
get_data() {
cat <<EOF
    {
        "title": "PR title",
        "head": $Branch,
        "base": "development",
        "body": "PR description"
    }
EOF
}

echo $(get_data) # <----------------- I can see my value of the variable $Branch here

curl -X POST \
    -H "Accept: application/vnd.github.v3+json" \
    -d "$(get_data)" \ # <----------------- But here I'm facing "Problems parsing JSON"
    -u my_user:my_token \
    https://api.github.com/repos/my_user/$Repo/pulls

open https://github.com/my_user/$Repo/pulls

如何正确地将我的变量设置到 curl 中?

$Branch也需要引用:

get_data() {
  cat <<EOF
    {
        "title": "PR title",
        "head": "$Branch",
        "base": "development",
        "body": "PR description"
    }
  EOF
}