Answer the question
In order to leave comments, you need to log in
How to make post request xml?
I tried to write it myself, but apparently I misunderstood something.
there is an xml request like
<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<ApiKey>xxxxxxxxxxxxx</ApiKey>
<Data xsi:type="Subscriber">
<Mode>mode</Mode>
<Force>false</Force>
<ListId>1</ListId>
<Email>[email protected]</Email>
<Firstname>testName</Firstname>
</Data>
</ApiRequest>
Answer the question
In order to leave comments, you need to log in
POST cannot be unnamed, there must be a field in which the data will be transferred, in your case it is xml. The essence is not entirely clear, you need to decide on which side of the server or client api?
It is allowed to send "unnamed" data in POST. The files are transferred somehow :)
stackoverflow.com/questions/871431/raw-post-using-curl-in-php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://url/url/url" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, "body goes here" );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
$result=curl_exec ($ch);
cUrl has the ability to send POST requests.
Just to get started, you need to know the name of the field in order to insert the XML content there.
Check with who provides the API. I met various options, some expect that application / x-www-form-urlencoded will come, others that multipart / form-data, others that application / xml or text / xml, and someone can invent something of their own like application/mysite+xml.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question