# Execute curl on environment variable variable

**URL:** <https://discuss.circleci.com/t/execute-curl-on-environment-variable-variable/45056>\
**Category:** Deployments\
**Tags:** circle-yml\
**Created:** [August 12, 2022, 3:17pm UTC](https://discuss.circleci.com/t/execute-curl-on-environment-variable-variable/45056 "2022-08-12T15:17:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chibi](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/chibi/32/31734_2.png) [@chibi](https://discuss.circleci.com/u/chibi)\
**Post date:** [August 12, 2022, 3:17pm UTC](https://discuss.circleci.com/t/execute-curl-on-environment-variable-variable/45056/1 "2022-08-12T15:17:11Z")

</div>

Hi! In one of my steps, I need to autenticated on an API, and I don’t want to expose the authentication, so my idea was to put the authentication curl on an environment variable so I have something like this:

on my config.yml file:

```auto
- run:
          name: Send Report
          when: always
          command: |
            token= $API_TOKEN
            curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data @"merged-test-results.json" "http://example.com/api/import/report/" 

```

My environment variable is the authentication curl like this:

```auto
curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"XXXXXXXXXXX\",\"client_secret\": \"XXXXXXXXX\" }
" "http://example.com/api/v1/authenticate"| tr -d '"'

```

When I run this on bash works fine, but running on Circle CI I got this error:

```auto
#!/bin/bash -eo pipefail
token= $API_TOKEN
curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data @"merged-test-results.json" "http://example.com/api/import/report/"  

curl: (6) Could not resolve host: application
curl: (6) Could not resolve host: \"client_id\"
curl: (6) Could not resolve host: \"XXXXXXXXXXXXXXXXXX\",\"client_secret\"
curl: (6) Could not resolve host: \"XXXXXXXXXXXXXXXXXXXXXXXXXXXX\"
curl: (3) unmatched close brace/bracket in URL position 1:
}
 ^

Exited with code exit status 6
CircleCI received exit code 6

```

Am I doing something wrong? What is the correct way of a curl like this on a variable?

---

<div class="post-metadata">

**Author:** ![ryankienstra](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ryankienstra/32/28970_2.png) [@ryankienstra](https://discuss.circleci.com/u/ryankienstra)\
**Post date:** [August 21, 2022, 12:04am UTC](https://discuss.circleci.com/t/execute-curl-on-environment-variable-variable/45056/2 "2022-08-21T00:04:23Z")

</div>

Hi @chibi,  
In case you haven’t already, it might help to go to [app.circleci.com](http://app.circleci.com) and click ‘Rerun Job with SSH’, and see if that bash command, or some variation of it, works there.

 ![Screen Shot 2022-08-20 at 7.03.07 PM](https://global.discourse-cdn.com/circleci/original/3X/1/a/1aa48bec9184f41de44b7e2d9e0e3f5228042f54.png)
