APIs & Integrations

Caterpy
Member

Ambiguous documentation of the accounting API extension

Hi,

 

I'm trying to use the accounting extension endpoints to get invoice details by id but it's not working and the documentation is kinda unclear.

 

I'm making the following call:

 

 

params = {'accountId': account_id, 'invoiceId': invoice_id}
r = requests.get(f'https://api.hubapi.com/crm/v3/extensions/accounting/invoice&hapikey={HUB_SPOT_API_KEY}', params= params)

 


I'm getting a 404 response but the invoice is right there and I see it when I login to my hubspot account. 
I even tried setting invoice_id to that of the invoice in hubspot and to that of the invoice in quickbooks but still nothing.

And the documentation of the hubspot api client in python is not functional.
1. There's a weird import: from hubspot.crm.extensions.accounting.invoice import 
and that's it, it doesn't say what to import 

2. If I copy paste the example the exact way and make the api call, I get the following Exception:

AttributeError: 'Discovery' object has no attribute 'invoice'

Can someone explain what am I doing wrong ?

0 Upvotes
5 Replies 5
Caterpy
Member

Ambiguous documentation of the accounting API extension

@dennisedson Any chance anyone else could help out with this ?  A dev maybe ?

0 Upvotes
SRoy
Participant | Gold Partner
Participant | Gold Partner

Ambiguous documentation of the accounting API extension

@Caterpy Don't you need a "/?" in your call to pass the querystring values? 😀

 

params = {'accountId': account_id, 'invoiceId': invoice_id}
r = requests.get(f'https://api.hubapi.com/crm/v3/extensions/accounting/invoice/?hapikey={HUB_SPOT_API_KEY}', params= params)

 

You were also right about the two points on the Python code on the official documentation page.

Try client.crm.extensions.accounting.invoice_api.get_by_id instead of client.crm.extensions.accounting.invoice.invoice_api.get_by_id.

 

I will advice you to read the raw code of the hubspot-api-client library to avoid being stuck on the discrepencies of the documentation. The python library is otherwise pretty robust (since it is auto generated from API schema)

 

@dennisedson  Sorry fo missing the notification and for late reply.

 

Regards,

Sujoy

0 Upvotes
Caterpy
Member

Ambiguous documentation of the accounting API extension

Hello @SRoy 

Hi Sroy,

First of all, thanks for the response.

What you're proposing is not really doable right now for budget purposes.

We just want to code it using hubspot's api, and I've had a look at the solutoins you've proposed and none of them work.

 

InvoiceApi.get_by_id(invoiceId, accountId) 

 

this throws the following exception

 

AttributeError: 'HubSpot' object has no attribute 'client_side_validation'

 

 So it doesn't solve the issue.

And concerning the second problem, the last "/" is not needed since there's no more routing that needs to be done and I did try it but still nothing.

And just FYI, I tried using invoice ID from both platforms, e.g Quickbooks and Hubspot.

One last question, where would I get "accountId" from, because now I'm just getting it from opening up an invoice's pdf directly from hubspot, and I fetch it from the URL.

0 Upvotes
SRoy
Participant | Gold Partner
Participant | Gold Partner

Ambiguous documentation of the accounting API extension

Sorry @Caterpy that my solution does not work for you. But it works for me. I thought if it would help you.

 


One last question, where would I get "accountId" from, because now I'm just getting it from opening up an invoice's pdf directly from hubspot, and I fetch it from the URL.


I am not sure if I understood your question. Your app supposed to know the accountId. The app which implements CRM Accoutning Extension API, must set the accountId of the user, as mentioned in
https://developers.hubspot.com/docs/api/crm/extensions/accounting

 

SRoy_0-1628431076870.png

 

I can not provide detailed process of how to implementet webhook and use Oauth token as it will take too much time out of me. I guess @dennisedson can help you to provide any extra-detailed official documentation or training/tutorial (if available) of CRM Accounting Extension API. Or I guess you may check/post in Hubspot slack channel.

 

Good luck.

dennisedson
HubSpot Product Team
HubSpot Product Team

Ambiguous documentation of the accounting API extension

@SRoy , any chance you could help out here?

0 Upvotes