How to Write a Quickbooks Online API Call to Query a Specific Customer Ref and Loop Through with Max Results of 10000?

This topic was automatically generated from Slack. You can find the original thread here.

Can you write me a Quickbooks Online API call to query the following

select * from Payment Where CustomerRef = ‘2640’

Max Results 10000, I also need to loop through

To query the Quickbooks Online API using the provided query, you can create a custom Pipedream code step using the axios package from @pipedream/platform. Here’s an example component that makes the request: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { quickbooksAccessToken: { type: "string", label: "Quickbooks Access Token", secret: true, }, companyId: { type: "string", label: "Company ID", }, }, async run({ $ }) { const query = "select * from Payment Where CustomerRef = '2640'"; const response = await axios($, { method: "GET", url: `https://quickbooks.api.intuit.com/v3/company/${this.companyId}/query`, headers: { Authorization: `Bearer ${this.quickbooksAccessToken}`, Accept: "application/json", }, params: { query, maxResults: 10000, }, }); return response; }, }); Replace quickbooksAccessToken and companyId with your actual Quickbooks access token and company ID. This component will make the API request and return the response. Please note that you’ll need to obtain the Quickbooks access token and company ID by following the Quickbooks OAuth2 flow. You can find more information on how to do that in the Quickbooks API documentation.

Can I use the quickbooks built in auth ?

Yes, you can use the built-in Quickbooks authentication when using Pipedream’s Quickbooks components. For example, if you want to perform a search query, follow these steps: 1. Search for the Quickbooks app from the step menu in your Pipedream workflow. 2. Select the “Search Query” action. 3. Connect your Quickbooks account. 4. Enter your query and any other required information. 5. At the bottom of the step, click “Test” to run the action and test the configuration. This way, you don’t need to manage the authentication manually, as Pipedream handles it for you.

I mean this

**import** { axios } **from** "@pipedream/platform"
export **default** defineComponent({
props: {
quickbooks: {
type: "app",
app: "quickbooks",
}
},
**async** run({steps, $}) {
return **await** axios($, {
url: https://quickbooks.api.intuit.com/v3/company/${**this**.quickbooks.$auth.company_id}/companyinfo/${**this**.quickbooks.$auth.company_id}`,`
headers: {
Authorization: Bearer ${this.quickbooks.$auth.oauth_access_token},
"accept": application/json,
"content-type": application/json,
},
})
},
})

And then use in the API call?

Yes, you can use the provided code with the built-in Quickbooks authentication and modify the API call to perform your desired query. Here’s the updated component code: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { quickbooks: { type: “app”, app: “quickbooks”, }, }, async run({ $ }) { const query = “select * from Payment Where CustomerRef = ‘2640’”; const response = await axios($, { method: “GET”, url: https://quickbooks.api.intuit.com/v3/company/${this.quickbooks.$auth.company_id}/query, headers: { Authorization: Bearer ${this.quickbooks.$auth.oauth_access_token}, Accept: “application/json”, “Content-Type”: “application/json”, }, params: { query, maxResults: 10000, }, }); return response; }, });

curious if this worked for you?

not off the bat, but maxResults need to be in the const query…

could have written it, but low on time.

Curious — are you on the Advanced plan? The code gen product in the UI is purpose-built for writing code and has access to product docs (where Pi does not yet). If you haven’t tried it yet, we also offer trials of the Advanced plan if you want to give it a shot.

Yeah I saw that AI, not sure actually on my plan will need to check that out. thanks for the heads up.

Im usually pretty good, just I hate the QBO queries :slightly_smiling_face:

and documentation on their site

I’m trying to get Pi access to all the product docs of our integrated apps too so you don’t have to read them and can just ask Pi any questions about them, instead!

kind of like the web-browsing feature of ChatGPT, if you’ve used that

  • i acutally do that with some programs at the moment

with my ChatGPT4 connection

yes exactly, cool

Really it getting it to read a the original docs, and then changelog (some APi’s docs are better than others).

I also found that (in the case of QBO for example), that the docs are not exactly correct

so there needs to also be like a “internal cheetsheet/knowledgebase” if that makes sense