cURL REST API do not works in .bat file

Ema5
Giga Contributor

Hello,

I created a curl to extract all incident resolved last 15 minutes.

curl -v -u "username:password" "https://<myinstance>/api/now/table/incident?sysparm_query=resolved_atONLast%2015%20minutes%40javascript%3Ags.minutesAgoStart(15)%40javascript%3Ags.minutesAgoEnd(0)" \ --request GET \ --header "Accept:application/json" \ --insecure --noproxy '*' > F:\Incident_List.js

If I run this curl on cmd, the curl work fine.

If I run the curl in .bat file, the curl do not works (the code extract all incident).

My .bat file is the following:

@ ECHO OFF

curl -v -u "username:password" "https://<myinstance>/api/now/table/incident?sysparm_query=resolved_atONLast%2015%20minutes%40javascript%3Ags.minutesAgoStart(15)%40javascript%3Ags.minutesAgoEnd(0)" \ --request GET \ --header "Accept:application/json" \ --insecure --noproxy '*' > F:\Incident_List.js

exit

Why the .bat file do not works as my expect? Is there any special characters to avoid?

Regards

1 ACCEPTED SOLUTION

Hello,



I fixed inserting double '%' for every character '%'.



Regards


View solution in original post

3 REPLIES 3

Chuck Tomasi
Tera Patron

Is that all on one line? If so, you shouldn't need those backslashes (\) before the -- arg delimiters. Try it without those and let me know.


Hello,



I fixed inserting double '%' for every character '%'.



Regards


Thanks for sharing Ema. It's been a long time since I did batch files. Now that you say that, I remembered. Good job!