# Passing a variable with the Groups API

**URL:** <https://devforum.okta.com/t/passing-a-variable-with-the-groups-api/18972>\
**Category:** Questions\
**Created:** [January 20, 2022, 3:26am UTC](https://devforum.okta.com/t/passing-a-variable-with-the-groups-api/18972 "2022-01-20T03:26:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![carndt87](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@carndt87](https://devforum.okta.com/u/carndt87)\
**Post date:** [January 20, 2022, 3:26am UTC](https://devforum.okta.com/t/passing-a-variable-with-the-groups-api/18972/1 "2022-01-20T03:26:38Z")

</div>

Hello. I am new to Okta and am trying to get familiar with the API. I was working on a script that could create multiple Groups in our new Okta tenant but with the way the curl command is formatted my array variable is not being read. I’ve used other APIs but not one that seems to require this kind of formatting. The variable is just read as plain text and a Group is made with the name of the variable. Here is my script for reference. Thanks in advance!

````auto
#!/bin/bash

array=("IT" "Engineering" "Finance")

for i in "${array[@]}"
do	
	curl POST \
	-H "Accept: application/json" \
	-H "Content-Type: application/json" \
	-H "Authorization: SSWS $api_key" \
	-d '{
		"profile": {
			"name": "$i"
		}
	}' "https://$oktadomain/api/v1/groups"
done```
````

---

<div class="post-metadata">

**Author:** ![sigama](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/sigama/32/5811_2.png) [@sigama](https://devforum.okta.com/u/sigama)\
**Post date:** [January 20, 2022, 7:59pm UTC](https://devforum.okta.com/t/passing-a-variable-with-the-groups-api/18972/2 "2022-01-20T19:59:29Z")

</div>

Hi @carndt87!

Can you try the following instead:

```auto
#!/bin/bash

array=("IT" "Engineering" "Finance")

for i in "${array[@]}"
do
  curl -v -X POST
  -H "Accept: application/json" \
	-H "Content-Type: application/json" \
	-H "Authorization: SSWS $api_key" \
	-d '{
		"profile": {
			"name": "'$i'"
		}
	}' "https://$oktadomain/api/v1/groups"
done

```

I made sure to preserve the iterator, i, per bash formatting as mentioned here [shell - Difference between single and double quotes in Bash - Stack Overflow](https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash)

---

<div class="post-metadata">

**Author:** ![carndt87](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@carndt87](https://devforum.okta.com/u/carndt87)\
**Post date:** [January 20, 2022, 8:12pm UTC](https://devforum.okta.com/t/passing-a-variable-with-the-groups-api/18972/3 "2022-01-20T20:12:38Z")

</div>

That did it. Thank you so much!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 21, 2022, 8:13pm UTC](https://devforum.okta.com/t/passing-a-variable-with-the-groups-api/18972/4 "2022-01-21T20:13:18Z")

</div>

Closed on January 21, 2022, 8:13pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
