Jump to content

Recommended Posts

Posted

I am using the endpoint /sales_invoices/{key} to retrieve a sales invoice.  I also specify the following parameters:

"attributes" = "reference,vendor_reference,date,last_paid,net_amount,shipping_net_amount,tax_amount,total_paid,contact_id"
"nested_attributes" = "contact"

The API documentation suggests that I should be able to retrieve the nested data for contact, however the returned contact is null.
The API documentation showing the sample payload also suggests that the contact_id might be returned as a field in the main body, hence I have added this to my attribute list, however this is also returned as null.
The other data is returned as expected.

Any suggestions on how to retrieve the contact key for a sales invoice and sales credit note?

 

 

Posted

Hi Stuart,

Are you able to provide the response body please(please mask any data that may be traceable to the business)?

The standard response for a GET request to sales_invoices/id should include the contact _id without requesting the nested_attributes. The below is taken from a response to sales_invoices/id.
 

"contact": {
"id": "e861ddf68bdd4bf3950c8084cd9ec13d",
"displayed_as": "Bronson Inc (BRO001)",
"$path": "/contacts/e861ddf68bdd4bf3950c8084cd9ec13d"
},
Posted

This is all I get:

{{
  "id": "8057948faa504a7ea77f6399c7ae0408",
  "displayed_as": "SI-1008542",
  "$path": "/sales_invoices/8057948faa504a7ea77f6399c7ae0408",
  "date": "2022-11-30",
  "reference": "DN 19676",
  "shipping_net_amount": "51.0",
  "net_amount": "3242.72",
  "tax_amount": "12.83",
  "total_paid": "0.0",
  "last_paid": ""
}}

I am using the 32 character guid to retrieve the data.  I need to get data for pro-forma which don't have a numeric id assigned.

Posted

OK, so I just tried it without specifying ANY attributes.  The API documentation states that this will only return the "base attributes (name, path)" however it has returned the full data set including nested data such as contact.

Poorly written documentation or am I missing something?

Posted

Thanks for the update Stuart, that is odd behaviour, I would expect the parameters to have been ignored and the response returned as you're now seeing it.

The doc's could definitely do with updating around swagger.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...