Post

Curl

Curl is the universal thing for web request.

Sometimes it is better to avoid new dependency as postman, ets.

src
https://curl.se/docs/tutorial.html
https://man7.org/linux/man-pages/man1/curl.1.html
  • Keys I used in examples

  • -k to switch off certificate checking
  • -v verbose information
  • user - login and password

  • You can send SOAP request this way:
1
2
3
4
5
6
7
8
9
10
curl --request 'POST' -v -k \
--url 'https:...' \
--user login:password \
--header 'Content-Type: text/xml;charset=UTF-8' \
--header 'SOAPAction: "http:/foo.ru/LIST"' \
--output result.xml \
--data-binary '<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv
...
</soapenv:Envelope>'
1
2
3
4
5
6
7
curl --request 'POST' -v -k \
--url 'https:...' \
--user login:password \
--header 'Content-Type: text/xml;charset=UTF-8' \
--header 'SOAPAction: "http:/foo.ru/LIST"' \
--output result.xml \
--data-binary $data.xml

Very useful library jq (repo)

  • These are just examples:
1
2
3
4
5
6
7
8
9
10
curl -k -v 'https://bar.net:21870' \
-H 'Accept-Charset: utf-8' \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Connection: close' \
--no-progress-meter \
-H 'Test: test' \
-d '{
"orderId": "1",
"productType": 0
}' | jq
1
2
3
4
5
6
7
8
9
10
11
12
13
curl -k 'https://bar.net:21870' \
-H 'Accept-Charset: utf-8' \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Connection: close' \
--no-progress-meter \
-H 'Test: test' \
-H 'Client: 15' \
-d '{
"orderId": "2",
"OfferId": "1",
"type": 0,
"CreditSum": 100.00,
}' | jq
This post is licensed under CC BY 4.0 by the author.