warrenbuckley Posted May 23, 2016 Share Posted May 23, 2016 Hello all,i am building my first custom workflow that queries an API to display results in the auto-suggest dropdown and returns the new JSON format for Alfred3 workflows. This works perfectly fine in the query is a single word, but if the query is multiple words then only the first word is sent as part of the querystring.So is there a way to do a cURL request with this query containing spaces? My current bash script in the list filter looks like so: #The base URL moved away from WebTask.io to Azure Functions baseurl='https://umbraco-alfred.azurewebsites.net/api/OurUmbNodeJS' #The Type QS parameter typeparam='type=' #The Query QS parameter queryparam='query=' #The Search query parameter from the last alfred workflow question query=$1 #Concact the URL fullurl=$baseurl$typeparam$searchtype$queryparam$query #What I had originally building up the string to do a curl on #curl fullurl #Even tried this with no luck curl -G -v $baseurl --data-urlencode --data-urlencode $typeparam$searchtype --data-urlencode $queryparam$query Link to comment
warrenbuckley Posted May 23, 2016 Author Share Posted May 23, 2016 Update for anyone else reading this. I resolved it by manually replacing spaces with 20% with the following below #The base URL moved away from WebTask.io to Azure Functions baseurl='https://umbraco-alfred.azurewebsites.net/api/OurUmbNodeJS?' #The Type QS parameter typeparam='type=' #The Query QS parameter queryparam='&query=' #The Search query parameter from the last alfred workflow question query=$1 #Replace spaces in the query with 20% to url-encode it query=${query// /%20} #Concact the URL fullurl=$baseurl$typeparam$searchtype$queryparam$query #make the request with curl curl $fullurl #curl example with get #curl -G -v $baseurl --data-urlencode $typeparam$searchtype --data-urlencode $queryparam$query dunkaroo 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now