A
A
Andrey2017-09-29 14:16:33
linux
Andrey, 2017-09-29 14:16:33

How to send data using post method using curl?

You need to send a POST request to the URL https://integration.cdek.ru/new_orders.php with the xml_request variable filled in, in which the contents of the XML file are transmitted.
I do

curl -X POST https://integration.cdek.ru/new_orders.php -H 'Content-Type: multipart/form-data' -H 'Content-Type: application/x-www-form-urlencoded' \
  -F 'xml_request=<?xml version="1.0" encoding="UTF-8"?>
<DeliveryRequest Number="236" Date="2010-10-14" Account="abc123" Secure="abcd1234" OrderCount="2">
    <Order Number="5403" DeliveryRecipientCost="0" SendCityCode="270" RecCityCode="44" RecipientName="Васина Юлия Александровна" Phone="7810999, 9295849151" Comment="Офис группы компаний Ланит. При приезде позвонить на мобильный телефон." TariffTypeCode="5" RecientCurrency="RUB" ItemsCurrency="RUB">
        <Address PvzCode="MSK2"></Address>
        <Package Number="1" BarCode="101" Weight="630">
           <Item WareKey="25000050368" Cost="49" Payment="49" Weight="68" Amount="1" Comment="Дидактические игры-занятия в ДОУ Ст.возраст Вып. 1"></Item>
        </Package>
        <AddService ServiceCode="30"></AddService>
        <Schedule>
           <Attempt ID="1" Date="2010-10-15" TimeBeg="09:00:00" TimeEnd="13:00:00" />
           <Attempt ID="2" Date="2010-10-16" TimeBeg="14:00:00" TimeEnd="18:00:00" RecipientName="Прокопьев   Анатолий Сергеевич" />
        </Schedule>
    </Order>
</DeliveryRequest>'

But an error comes out:
curl: (26) couldn't open file "?xml version="1.0" encoding="UTF-8"?>
<DeliveryRequest Number="236" Date="2010-10-14" Account="abc123" Secure="abcd1234" OrderCount="2">
    <Order Number="5403" DeliveryRecipientCost="0" SendCityCode="270" RecCityCode="44" RecipientNa

What is the correct way to write the request so that it doesn't try to open the file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
planc, 2017-09-29
@planc

escape with \
or you can open the network tab in chrome dev tools, make a request and find it there, right-click -> copy as curl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question