Multiline curl command

前端 未结 3 1535
深忆病人
深忆病人 2020-12-17 08:55

I am trying to modify a curl request that was captured with Google Chrome Dev Tools.

Here is what the command looks like

curl \"http://WEBSITE\" -H \         


        
相关标签:
3条回答
  • 2020-12-17 09:49

    Use the \ escape character for multiline inputs

    curl "http://WEBSITE" -H "Host: WEBSITE"\
    -H "Accept: text/html,application/xhtml+xml\
    ,application/xml;q=0.9,*/*;q=0.8" 
    
    0 讨论(0)
  • 2020-12-17 09:56

    NOTE: watch out for the tendency to indent on multiple line commands, as it will embed spaces and screw up the curl command. the sed command replaces embedded spaces within the variables with the %20 string so that spaces can be used embedded in the strings you pass as variables

    messageout="The rain in Spain stays mainly in the plains"
    summaryout="This is a test record"
    alertnameout="Test Alert"
    
    
    curl -v -silent request POST "URL.com?\
    summary=`echo $summaryout | sed -e 's/ /%20/g'`&\
    alertname=`echo $alertnameout | sed -e 's/ /%20/g'`&\
    message=`echo $messageout | sed -e 's/ /%20/g'`"
    
    0 讨论(0)
  • 2020-12-17 10:00

    If you are running Windows, I have found it easier to install Git and use Git Bash to run Curl. This was initially suggested in a separate article: https://stackoverflow.com/a/57567112/5636865.

    0 讨论(0)
提交回复
热议问题