How to Add a Body to a POST Request in Node.js

Hello,

I was trying to create a POST request, namely Create an Order, but I do not know how to add a Body to the request. I have gotten the Request URL from the API docs and I was able to use it in my code, but I need a way of editing the info. Could someone look at my gist on Github?

Best,
Jordan

Infusionsoft has a Node SDK which will save you time in developing the API calls yourself.

PS: I recommend that you erase the Access Token entry from public view.

I’ve looked at infusionsoft-sdk-nodejs without joy and am now using axios to call rest end point. Axios has plenty of decent help on usage.

I couldn’t figure out where to start with sdk-nodejs as example doesn’t work and I suspect you have to deploy as npm module first or clone repository and then include it via local file in package.json - plus it’s actually not complete and is missing end points which makes little sense.

An summarized example for post would be:
axios.post(url, body, {headers: headers})
.then((res) => {
console.log(‘got token’, res.data)
})
.catch((err) => {
console.log('AXIOS Error: ', err)
})

In regards to the Infusionsoft Node SDK it seems to be maintained by @TomScott.
Although it does seem odd that nothing been updated for 2 years now.

Looking through the other libraries I did come across this Node Sample Library.

Although that was not clear enough on how it is handling the OAuth Tokens.

I know that other developers have made Node JS - Infusionsoft Integrations, but I have no idea what they have used. The earlier ones would have been based on using the XML-RPC API functions. You will have to experiment with things to make it work.

I could never get var infusionsoftSDK = require('infusionsoft-sdk') to work so gave up on the infusionsoft sdk and rather used it as documentation together with their interactive rest calls on website.

Wish I would’ve seen this 2 hours ago, I’m right there with you! I couldn’t get past it either.