Unable to encode JSON in a Gitlab Yaml Pipeline

I’m unable to submit Dropbox API request from YML Gitlab Pipeline using PowerShell (Windows runner). The API requires to pass a JSON as a header parameter and encoding that JSON into YML Gitlab Pipeline doesn’t work:

`--header "Dropbox-API-Arg:{\"path\":\"/$BUILD_FILENAME\"}"

The full script step is below as it’s now defined in YML:

- C:\Windows\System32\curl.exe -X POST https://content.dropboxapi.com/2/files/upload --header "Authorization:Bearer $DROPBOX_TOKEN" --header "Content-Type:application/octet-stream" --header "Dropbox-API-Arg:{\"path\":\"/$BUILD_FILENAME\"}" --data-binary @$BUILD_FULLFILENAME

The response error is below:

Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": could not decode input as JSONcurl: (3) Port number ended with '\'

I can execute the command above in Windows PowerShell on the same PC where the runner is without any issues:

curl -X POST https://content.dropboxapi.com/2/files/upload --header "Authorization: Bearer XXX" --header "Dropbox-API-Arg: {\"path\": \"/README.md\"}" --header "Content-Type: application/octet-stream" --data-binary @README.md

How can I encode the JSON properly so it can be executed and pass to the CURL as expected?

I believe the answer to this question can be found here: https://stackoverflow.com/a/64392947