Making a call to the API is simply a matter of opening a session connection to the Web Services gateway endpoint and passing credentials and requests in XML.
You can make a call to the Web Services API using various mechanisms, such by using Postman (a third-party app), or by using one of the Sage Intacct SDKs. You can even create an application using your preferred programming language natively.
When making API calls, be aware that you aren’t interacting directly with the Sage Intacct database. Instead you are going through the Sage Intacct business layer, which saves you a lot of work. For example, when you post an invoice, you don’t need to make all the related journal entries and so forth. The business layer performs those updates for you.
This document outlines the different mechanisms for interacting with the gateway and also provides examples of test applications using various programming languages.
Use Postman
Postman is a popular API test tool that lets you send HTTP requests to a server and review the responses. Postman supports collections of commonly-used requests that can be reused and modified. You can download the Sage Intacct API collection, which provides a set of API calls by application:
See Your First XML API Calls to learn how to use Postman to send requests to the gateway and to download the Sage Intacct API collection.
Use an SDK
Using one of the Sage Intacct SDKs is preferable to using a native programming language as the SDK nicely wraps functionality and provides session management under the hood.
To begin using the SDK for PHP, work through the Getting Started topic, which takes you from set up to sending your first request.
Any programming language that lets you post HTTP requests can be used to create a Web Services application. This section provides some sample test applications using different languages.
Note: The examples provided here are for demonstration purposes and are not intended to be used directly in application code.
Having a separate request-generating program is recommended in order to maintain consistent calls. Accordingly, each test application is set up with:
A test program that constructs an XML request document and passes it a request-generating program via a post function call.
An XMLRequestClient that provides the post function, which accepts the XML request document, generates the full HTTP request with the headers, sends the request to the gateway, and returns the response.
The examples provide placeholders for your Web Services credentials as myWebSenderId and myWebPassword. In addition, the examples are set up to accept a hardcoded session ID as mySessionId for simplicity.
Important: You should always protect/encrypt your passwords. In addition, when you are working with production code, using the getAPISession function to get a session ID and endpoint is always the recommended approach.
The Python and Java third-party libraries/modules used in the examples were chosen largely for ease of use and compatibility with given versions of programming languages. Feel free to use other approaches.
Python 2.7 Example
Construct the Request and Call Post
The following test program creates an XML request using the ElementTree module. The program then uses a static method on the XMLRequestClient class (description further down) to post the request to the gateway using the urllib2 module.
Post the Request and Return the Response
The XMLRequestClient class provides a post method that accepts an Element instance, opens a connection using urllib2, posts the request, and returns the response.
Python 3.5 Example
Construct the Request and Call Post
The following test program creates an XML request using the minidom module. The program then uses a static method on the XMLRequestClient class (description further down) to post the request to the gateway using the urllib module.
Post the Request and Return the Response
The XMLRequestClient class provides a post method that accepts an minidom Document instance, opens a connection using urllib, posts the request, and returns the response.
Java 8 Example
Construct the Request and Call Post
The following test program creates an XML request using the DocumentBuilder package. The program then uses a method available on an XMLRequestClient instance (class description further down) to post the request to the gateway using the HttpsURLConnection package.
Post the Request and Return the Response
The XMLRequestClient class sets the Sage Intacct Web Services endpoint and provides a post method that accepts a Document, opens a connection using HttpsURLConnection, posts the request, and returns the response.