I want to write API's in confluence
but I am getting confused where to write it.
I am using ubuntu 16.04 and my confluence is installed in /opt/atlassian
also there is one more folder in /var/atlassian
now I am writing api's using php which are located in /var/www/html/confluence_api
<?php
$data = {
"type":"page",
"title":"My Test Page",
"space":{"key":"TST"},
"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}
};
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:8090/rest/api/content/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "*****" . ":" . "*****");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
print_r($result);
?>
and I am using POST method for calling the API but I am getting 404 http_code in return
GET method is working fine but not POST
please answer me ASAP
I'm not even sure how you came up with the idea of wedging bits of code in the wrong language into Confluence is a good idea.
If you want to add new APIs to Confluence, you should write the end points in Java in an App you add to Confluence.
If you want to use the APIs in Confluence, you can use php (or other languages), but do not put your code inside the Confluence installation, that can break all sorts of things.
The content call you are using expects to be a get, not a post, that's why you get a 404.
hey thanks @Nic Brough -Adaptavist- for your reply
my requirement is PHP so I am writing APi's in php language. I created separate folder for api's and not in the confluence setup.
now working it is as expected
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.