borna
borna

Reputation: 924

Provide input file to CURL command

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'' \
]}"

Upvotes: 5

Views: 18949

Answers (1)

Gereon
Gereon

Reputation: 17844

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

Upvotes: 13

Related Questions