My plan was first make it work using the postman client
and port the same using curl
request . So first i made a curl request from command line as
curl --include --request POST --user username:password --header 'Content-type: application/hal+json' http://192.168.1.243/node --data-binary '{"_links":
{"type":{"href":"http://192.168.1.243/rest/type/node/article"}}, "title":[{"value":"My first page"}],"body":[{"value":"How are you?"}]}'
And that was worked (created the node in 192.168.1.243
) . Then i made the curl
request from php as follows :
$data = '{"_links":
{"type":{"href":"http://192.168.1.243/rest/type/node/article"}}, "title":[{"value":"My first page"}],"body":[{"value":"How are you?"}]}';
$url = "http://192.168.1.243/node";
$curl_connection = curl_init($url);
curl_setopt($curl_connection, CURLOPT_COOKIEFILE, "/tmp/cookie.txt");
curl_setopt($curl_connection, CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_connection, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl_connection, CURLOPT_HTTPHEADER, array('Content-type: application/hal+json'));
curl_setopt($curl_connection, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl_connection, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
And that was all . The node created
in the remote server .
In postman client cant set the HEADER
as 'Content-type: application/hal+json'
. I think that may caused the issue . Any insights welcome .