Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Provide input file to CURL command

Tags:

curl

I have the following curl command which works if I run it from the command line. As you can see, I am basically adding users test1, test2 and etc to some external server using rest call.

curl -i -H "Accept:appliaction/json" --user admin:admin \
--data "{'admin_id':'sec_master','admin_pwd':'password','commands': \
[ \
'user create -no-password-policy test1 uid=test1,dc=something,dc=com test1 
test1 password123', \
'user create -no-password-policy test2 uid=test2,dc=something,dc=com test2 
test2 password123'' \
]}" -k https://myhost/isam/pdadmin/

Since eventually I am going to add like over 100K users, is there a way provide an input file with the list of the users to curl?

Like maybe read this portion of it from a file?

--data "{'admin_id':'sec_master','admin_pwd':'password','commands': \
[ \
'user create -no-password-policy test1 uid=test1,dc=something,dc=com test1 
test1 password123', \
'user create -no-password-policy test2 uid=test2,dc=something,dc=com test2 
test2 password123'' \
]}"
like image 507
borna Avatar asked Jul 18 '26 14:07

borna


1 Answers

Use curl --data @users.json, and put the JSON data you're posting into the users.json file.

like image 195
Gereon Avatar answered Jul 21 '26 10:07

Gereon