brimstone brimstone - 3 years ago 215
Swift Question

Call Quickbooks API

I want to be able to call the Quickbooks API for a test app I've made on Intuit Developer. The app is made in Xcode, using Swift, here's what I have so far:

var request = NSMutableURLRequest(URL: NSURL(string: "*%20FROM%20Customer")!)
request.HTTPMethod = "GET"
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {
(response, data, error) in

if error == nil {
if let HTTPResponse = response as? NSHTTPURLResponse {
let statusCode = HTTPResponse.statusCode
if statusCode == 200 {


The error says that "The operation couldn't be completed". I'm doing this in a Sandbox Company, is this the reason why? If I entered a real company ID would it work? Also, how can I use the API?

Answer Source

There is no way to generate tokens entirely from your mobile app.

Using consumerKey and consumerToken, you can generate accessToken and accessSecret from the OAuthPlayground. PN - After completing C2QB(OAuth) flow, you should use 'App Menu API Test.' option which will show you accessToken and accessSecret.

After getting those 4 tokens, you can make any calls. For that you should use any standard OAuth lib(swift) like - PN - I've not tried it yet(I just found it after doing a lil search in net).

PFB post where I'd shared java code which used signPost OAuth lib. You can covert that to swift(using OAuthSwift or any other suitable lib). How to call API (Oauth 1.0)?


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download