Skip to content

Commit c850f79

Browse files
author
Sandeep Parmar
authored
Merge pull request #52 from VeritasOS/curl_issue_urlencode
Url encode the name part of the data of the form name=content
2 parents 785f548 + 1c017bd commit c850f79

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

snippets/curl/get_nb_images.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ parseArguments()
6767
fi
6868
}
6969

70+
uriencode()
71+
{
72+
jq -nr --arg v "$1" '$v|@uri';
73+
}
7074
###############main############
7175

7276
parseArguments "$@"
@@ -84,7 +88,10 @@ data=$(jq --arg name $username --arg pass $password --arg dname $domainname --ar
8488
jwt=$(curl -k -X POST $uri -H $content_header -d "$data" | jq --raw-output '.token')
8589

8690
param1="filter=policyType eq 'Standard'"
87-
param2="page[limit]=10"
91+
92+
### To use filter page[limit] in URI, The key 'page[limit]' must be url encoded already. ###
93+
### Curl --data-urlencode encodes only the content part of the data of the form 'name=content' ###
94+
param2="$(uriencode 'page[limit]')=10" #op: page%5Blimit%5D=10
8895

8996
##############jobs##############
9097

snippets/curl/get_nb_jobs.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ parseArguments()
6767
fi
6868
}
6969

70+
uriencode()
71+
{
72+
jq -nr --arg v "$1" '$v|@uri';
73+
}
74+
7075
###############main#############
7176

7277
parseArguments "$@"
@@ -84,7 +89,10 @@ data=$(jq --arg name $username --arg pass $password --arg dname $domainname --ar
8489
jwt=$(curl -k -X POST $uri -H $content_header -d "$data" | jq --raw-output '.token')
8590

8691
param1="filter=jobType eq 'BACKUP'"
87-
param2="page[limit]=10"
92+
93+
### To use filter page[limit] in URI, The key 'page[limit]' must be url encoded already. ###
94+
### Curl --data-urlencode encodes only the content part of the data of the form 'name=content' ###
95+
param2="$(uriencode 'page[limit]')=10" #op: page%5Blimit%5D=10
8896

8997
##############jobs##############
9098

0 commit comments

Comments
 (0)