Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
645 views
in Technique[技术] by (71.8m points)

bash - Special characters within a GraphQL query in shell script

I'm using the GraphQL API from Pimcore to create Customers Objects within a simple shell script. Everything works fine except when names or lastnames are with special characters (in spanish) like:

á, é, í, ó, ú, ?

This is the code I'm using

 #!/usr/bin/env sh
OLDIFS=$IFS
IFS=";"
while read -r f1 f2 f3
do
curl -H "Content-Type: application/json" -d '{ "query": "mutation { createCustomer( key:"'${f1}'", parentId:703, input:{ firstname:"'${f2}'", lastname:"'${f3}'"} ) { success message }}"}' http://localhost/pimcore-graphql-webservices/shop?apikey=295b86489dca91a4aafaac8315cdb84a --insecure 
done < CUSTOMERS.csv
IFS=$OLDIFS

Is there any way to escape those? Or maybe a better way to do it? I've tried a lot of possibilities but couldn't make it work. Any help is appreciated.

question from:https://stackoverflow.com/questions/65947534/special-characters-within-a-graphql-query-in-shell-script

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...