Skip to content

Instantly share code, notes, and snippets.

@kijanawoodard
Created September 16, 2014 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kijanawoodard/a060a1e4ee7eb00a6e32 to your computer and use it in GitHub Desktop.
Save kijanawoodard/a060a1e4ee7eb00a6e32 to your computer and use it in GitHub Desktop.
IPP DevDefined POST TaxService
/* 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