Search code examples
quickbooksquickbooks-onlineintuit-partner-platform

Download PDF invoice using IPP .NET SDK for QuickBooks v3.0


I am using IPP .NET SDK for QuickBooks v3.0 in my .NET app to exchange the data between my app and QuickBooks Online. How can I download the PDF invoice from the QuickBooks using this SDK?


Solution

  • .Net SDK 2.2.0 has support for QBO v3 service upto v79 only. In case you need support for this, then you need to make direct http calls using dev defined library. Sample GET and POST requests are added below. Modify the same for PDF endpoint- https://developer.intuit.com/docs/api/accounting/Invoice

    GET https://gist.github.com/IntuitDeveloperRelations/0913b4c224de758fde0a

    POST

    //string res = CreateV3Customer(consumerKey, consumerSecret, accessToken, accessTokenSecret, realmId);
    public string CreateV3Customer(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret, string realmId)
        {
    
            StringBuilder request = new StringBuilder();
            StringBuilder response = new StringBuilder();
    
    
    
            var requestBody = "{\"FamilyName\":\"Jack\"}";
    
            HttpWebRequest httpWebRequest = WebRequest.Create("https://quickbooks.api.intuit.com/v3/company/"+realmId+"/customer") as HttpWebRequest;
            httpWebRequest.Method = "POST";
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Headers.Add("Authorization", GetDevDefinedOAuthHeader(consumerKey, consumerSecret, accessToken,accessTokenSecret,httpWebRequest, requestBody));
            request.Append(requestBody);
            UTF8Encoding encoding = new UTF8Encoding();
            byte[] content = encoding.GetBytes(request.ToString());
            using (var stream = httpWebRequest.GetRequestStream())
            {
                stream.Write(content, 0, content.Length);
            }
            HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse;
            using (Stream data = httpWebResponse.GetResponseStream())
            {
    
    
              string customerr = new StreamReader(data).ReadToEnd();
    
              return customerr;
    
            }
        }