How to define the basic HTTP authentication using cURL correctly?

后端 未结 2 1946
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-12 15:15

I\'m learning Apigility (Apigility docu -> REST Service Tutorial) and trying to send a POST request with basic authentication via cURL:

$ curl -X POST -i -H          


        
2条回答
  •  暖寄归人
    2020-12-12 15:45

    as header

    AUTH=$(echo -ne "$BASIC_AUTH_USER:$BASIC_AUTH_PASSWORD" | base64 --wrap 0)
    
    curl \
      --header "Content-Type: application/json" \
      --header "Authorization: Basic $AUTH" \
      --request POST \
      --data  '{"key1":"value1", "key2":"value2"}' \
      https://example.com/
    

提交回复
热议问题