4

I've been making curl requests to a long URL and saved the URL in a file named "url.txt". I then query that URL using the following command...

http://curl.haxx.se/docs/manpage.html#-K

curl -K ../url.txt

The url.txt file in this case contains the data which is in the following format...

url = "http://mycustomurl.com/index.json?param1=hello,param2=world...

The url gets quite long. I also wanted to pass headers with that file, which I can pass using -H flag as well. However, when using these two flags together, they do not seem to work as far as I can tell. Therefore, I'm trying to modify my url.txt file to take the following format, and just use the first curl statement.

header = "Accept: application/json"
url = "http://mycustomurl.com/index.json?param1=hello,param2=world...

The query still functions and returns the body of the page, but the header is not being properly passed to the server. I've checked my server logs to confirm. Is anyone able to shed any light on what I may be doing wrong in this instance? Any help would be greatly appreciated.

Thank you.

Michael
  • 71
  • 1
  • 1
  • 3
  • 1
    So what happens? "not being properly passed" you say, but show us the -v output of the request and we might spot the problem... – Daniel Stenberg Jan 11 '16 at 21:19
  • Oh that helps! I added the -v flag as you recommended and it appears the header is being passed properly in the request. My issue is that my server is not handling it as it should be. Thanks for the help! – Michael Jan 11 '16 at 21:30
  • Awesome. Glad to help! – Daniel Stenberg Jan 11 '16 at 21:53

1 Answers1

1

This helped me. how do I set a custom header in a curl config file

Should add -H "Accept:application/json" to your config file.

make sure trim a space

Yuri
  • 4,254
  • 1
  • 29
  • 46
smapira
  • 87
  • 7