0

I'm trying to do some API REST requests with the curl loop command below. With a first list of URL (with REST request inside), this works perfectly, with a second one I get "curl: (3) Illegal characters found in URL"

for i in `rest_a_url_list` ; do curl -H "Content-Type: application/json" -H "Auth-Token: $token" $i ; done

First url list with lines like : https://some.api.net/REST/ARESTCOMM/x/ Second list : https://some.api.net/REST/BRESTCOMM/x/x/xxxx

I also tried to put the curl loop output in a bash script and "bash -x myfile.sh" and got also an illegal char error. But when I cat my file and copy some lines to exec it works.

Bash -x output give some simple quotes in place of doubles and place a '$' just before url curl -D -H -X GET -H 'Content-Type: application/json' -H 'Auth-Token: $token' $'url'

I tested several times and always the result. Perhaps onather way to achieve this but all that is starting to confuse me. Any thoughts what wrong I am doing?

2
  • It may be a good idea to surround $i in quotes to prevent some possible problems. Also there could be something wrong with your list for all we know...
    – StefanR
    Commented Jul 13, 2019 at 19:21
  • There might be some character that needs to be encoded specially in your JSON document. What is the failing data that causes the error?
    – Kusalananda
    Commented Jul 13, 2019 at 19:39

1 Answer 1

0

I'm sorry there was some wrongs char in my url_list file, as I sed and tr on this file previous to use it in loop. All works fine now for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .