Created
September 16, 2014 23:34
-
-
Save kijanawoodard/a060a1e4ee7eb00a6e32 to your computer and use it in GitHub Desktop.
IPP DevDefined POST TaxService
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* post | |
{ | |
"TaxCode": "MyTaxCodeName", | |
"TaxRateDetails": [ | |
{ | |
"TaxRateName": "myNewTaxRateName", | |
"RateValue": "8", | |
"TaxAgencyId": "1", | |
"TaxApplicableOn": "Sales" | |
} | |
] | |
} | |
*/ | |
//query = "taxservice/taxcode" | |
public static string ExecuteV3Query(string query, string post = null) | |
{ | |
string uri = string.Format("https://quickbooks.api.intuit.com/v3/company/{0}/{1}", CompanyId, query); | |
HttpWebRequest httpWebRequest = WebRequest.Create(uri) as HttpWebRequest; | |
httpWebRequest.Method = post == null ? "GET" : "POST"; | |
httpWebRequest.Accept = "application/json"; | |
httpWebRequest.Headers.Add("Authorization", GetDevDefinedOAuthHeader(httpWebRequest, post)); | |
if (post != null) | |
{ | |
var bytes = new UTF8Encoding().GetBytes(post); | |
Stream postStream = httpWebRequest.GetRequestStream(); | |
postStream.Write(bytes, 0, bytes.Length); | |
postStream.Flush(); | |
postStream.Close(); | |
} | |
HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse; | |
using (Stream data = httpWebResponse.GetResponseStream()) | |
{ | |
return new StreamReader(data).ReadToEnd(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment