johnpduane / confluence-api Goto Github PK
View Code? Open in Web Editor NEWConfluence API wrapper for NodeJS
License: MIT License
Confluence API wrapper for NodeJS
License: MIT License
postContent
and putContent
callback positions are inconsistent other APIs. I'm happy to make a PR (with backward compatibility). LMK ๐
There should be an option that you can pass in the config to set a proxy. There is a library that extends superagent to allow for a proxy, see here.
I've got a site that needs to be imported into Confluence. People will view it in Confluence but it is not the authoritative source and so it needs to be imported often so Confluence gets the latest changes. I was looking at your library and at confluency. That other library has some useful functions, especially around dealing with children and retrieving all pages within a site. I would potentially use both during the import of this site to Confluence.
I want to also try out yours but the documentation is missing examples. In particular, I was hoping that .getCustomContentById()
would be powerful enough to get a list of children and maybe I could update pages with .putContent()
. It is difficult for me to divine how to use these methods when the totality of their documentation is a brief sentence and an explanation of parameter types.
Would you be willing to show examples in your readme? Also, is this library able to get all of the pages in a single space and get all of the children for a single page? Right now it appears that I will be using two Confluence libraries in order to scan for all pages (confluency), upload new pages by title (confluence-api), change page parents (both) and delete pages (both).
Would be real cool if these API calls would return a Promise and be chainable. Nothing wrong with callbacks to get the job done, but currently I am finding that I need to wrap everything in a promise which is a little annoying. Ideally we'd support both.
I can help with this by creating a PR, just let me know if that's something we'd want to do.
Hey there,
I've implemented a getUserByKey function, added documentation, and created a test (which needs a valid userKey to be added to pass, but which otherwise should). I've never submitted a pull request before, but it seems like I need permission to create the branch and then submit the request -- or let me know if there's some other way you'd rather I submitted.
Thanks for building this, it's been super helpful!
One of confluence-api 's dependencies is a security vulnerability https://github.com/liatrio/libotrio/network/alert/package-lock.json/superagent/open
Maybe I'm not doing something right here but when I execute the following, the page in question does get updated but it is moved out from under it's parent page and moved to the top of the space.
confluence.putContent(spacekey, pageId, version, title, content, function(err, data) {...});
I've verified that the all the required variables are correct and I do not get any errors.
More details: here is the complete function I'm trying to use. First, I use postContentByPageTitle method to get the pageId and version info. Then I pass those variables to the putContent method to update the target page.
function postContentByPageTitle(spacekey, title, content) {
setTimeout(function() {
console.log('Placing content in ' + spacekey + ':' + title + '.');
confluence.getContentByPageTitle(spacekey, title, function(err, data) {
try {
if (data.results[0].id) {
var version = parseInt(data.results[0].version.number) + 1;
confluence.putContent(spacekey, data.results[0].id, version, title, content, function(err, data) {
if (err) {
console.log(err);
} else {
console.log(' ' + title + ' has been updated.')
}
});
}
}
catch(error) {
console.log(error)
}
});
}, arguments.delay);
}
On Heroku I get the above error, the whole stacktrace looks like this:
[Fri Apr 22 2016 11:42:28 GMT+0200 (CEST)] ERROR TypeError: Cannot read property 'body' of undefined
at /app/node_modules/confluence-api/lib/confluence.js:162:34
at Request.callback (/app/node_modules/confluence-api/node_modules/superagent/lib/node/index.js:687:12)
at ClientRequest.<anonymous> (/app/node_modules/confluence-api/node_modules/superagent/lib/node/index.js:639:10)
at CleartextStream.read [as _read] (tls.js:472:13)
at ClientRequest.emit (events.js:95:17)
at SecurePair.emit (events.js:92:17)
at CleartextStream.socketErrorListener (http.js:1603:9)
at CleartextStream.emit (events.js:95:17)
at SecurePair.<anonymous> (tls.js:1400:19)
at CleartextStream.Readable.read (_stream_readable.js:341:10)
at writeOrBuffer (_stream_writable.js:216:5)
at SecurePair.maybeInitFinished (tls.js:980:10)
at doWrite (_stream_writable.js:226:10)
at EncryptedStream.Writable.write (_stream_writable.js:183:11)
at EncryptedStream.write [as _write] (tls.js:369:25)
at write (_stream_readable.js:602:24)
at flow (_stream_readable.js:611:7)
at emitReadable_ (_stream_readable.js:427:10)
at Socket.pipeOnReadable (_stream_readable.js:643:5)
at emitReadable (_stream_readable.js:423:5)
at Socket.emit (events.js:92:17)
at readableAddChunk (_stream_readable.js:166:9)
at Socket.Readable.push (_stream_readable.js:128:10)
at TCP.onread (net.js:529:21)
The same code works without problems locally, any idea what can be wrong?
Seeing UNABLE_TO_GET_ISSUER_CERT_LOCALLY
when making standard request via the api
as cert is internal.
ar Confluence = require("confluence-api");
var config = {
username: ""
password: "",
baseUrl: "https://.atlassian.net",
//version: 4 // Confluence major version, optional
};
var confluence = new Confluence(config);
confluence.getSpace("", function(err, data) {
// do something interesting with data; for instance,
// data.results[0].body.storage.value contains the stored markup for the first
// page found in space 'space-name' matching page title 'page-title'
console.log(data)
console.log(err)
});
when I run this the output is a {} and a null.
I know that there is a space and that it has information inside it.
This is connecting to a confluence cloud instance.
First off great repo thank you!!!
I have getContentByID
working however im struggling to get putContent
to work. Im fairly sure the issue lies in the sting passed to the content
parameter.
confluence.putContent(
"AI",
"1234567",
"2",
"Name of document",
'"body":{"storage":{"value":"<p>This is the updated text for the new page</p>","representation":"storage"}',
(err, data) => {
console.log("Started");
if (err) {
callback(null, { statusCode: 405, body: JSON.stringify(err) });
} else {
console.log(data);
callback(null, { statusCode: 200, body: JSON.stringify(data) });
}
}
);
Is my content
sting malformed?
Hi,
I am facing an issue, i am not able to update the content of available page in confluence. This is my sample request.
confluence.putContent(<space_id>,<page_id>,<current_versionId>, 'Test Page', '<h1>Updated</h1>', function (err, response) {
if (!err) {
console.log('Done');
} else {
console.log(err.message);
}
}, true);
When i run this, i am getting "Conflict" as an error response.
I tried to increment the version ID of the to the same page, but i am returning with "BAD REQUEST" as an error response.
First of all, thanks for a nice module. :)
It would be great to be able to use ancestors in the put request to put the page at the desired location/path in the same request. (E.g. the same place it was before the put.)
I will be happy to send a pull request but I would like to have your thoughts on how to implement it.
If you think it's worth implementing at all, that is.
Perhaps a new function could be implemented with options like the getCustomContentById?
Hello,
Many thanks for sharing this module! A question related to the tests you wrote:
https://confluence-api-test.atlassian.net/wiki is it a public test-server or your own, that you pay for?
Edi
I need to be able to provide custom expanders to getContentById. I can see in the current code that expand fields default to body.storage,version.
Two possible options;
Please let me which is preferred, happy to branch and provide pull request.
Hi!
When I try confluence-api I have Error :
Request has been terminated Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.
I select Enable development mode in my confluence cloud.
Thanks in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.