我想进行api调用,并将curl内容类型标头设置为application / json,
这里是使用测试服务postman-echo.com
的样本
Bash命令(在基于Unix的系统中使用单撇号:
$ curl --location --header "hfoo:hbar" --request GET "https://postman-echo.com/get?foo1=bar1"
Julia等效项:
julia> using HTTP; d = HTTP.request(:GET, "https://postman-echo.com/get?foo1=bar1",["hfoo"=>"hbar"]);
julia> println(String(d.body))
{"args":{"foo1":"bar1"},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-5ec438fa-c2bf3d5d8a300e08685f833d","content-length":"0","hfoo":"hbar","user-agent":"HTTP.jl/1.4.1"},"url":"https://postman-echo.com/get?foo1=bar1"}