# How to get/add attachment of sale & product in JSON

**URL:** https://discuss.tryton.org/t/how-to-get-add-attachment-of-sale-product-in-json/323
**Category:** Developer
**Created:** [March 20, 2017, 7:19am UTC](https://discuss.tryton.org/t/how-to-get-add-attachment-of-sale-product-in-json/323 "2017-03-20T07:19:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![piyush8191](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@piyush8191](https://discuss.tryton.org/u/piyush8191)
#### Post date: [March 20, 2017, 7:19am UTC](https://discuss.tryton.org/t/how-to-get-add-attachment-of-sale-product-in-json/323/1 "2017-03-20T07:19:05Z")

</div>

We are unable to get/add attachment of sale & product.  
Can I know the API request/method for it?

I am tryting to make json api request.

Thank you,

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [March 20, 2017, 8:31am UTC](https://discuss.tryton.org/t/how-to-get-add-attachment-of-sale-product-in-json/323/2 "2017-03-20T08:31:31Z")

</div>

All the attachments are stored on the \_ir.attachmen\_t model. The resource field is used as reference to the related method. So for getting all the attachments of a sale you have to perform a search on the _ir.attachment_ model filtering with the records that have _‘sale.sale,1’_ for the resorce field (replacing 1 with the id of the sale you want to read.

The same applies for product by using the correct method.

---

<div class="post-metadata">

### Author: ![piyush8191](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@piyush8191](https://discuss.tryton.org/u/piyush8191)
#### Post date: [March 20, 2017, 9:07am UTC](https://discuss.tryton.org/t/how-to-get-add-attachment-of-sale-product-in-json/323/3 "2017-03-20T09:07:07Z")

</div>

Thank you for your answer  
but still I am not clear with API request.

Can you give me an example for JSON?

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [March 20, 2017, 9:24am UTC](https://discuss.tryton.org/t/how-to-get-add-attachment-of-sale-product-in-json/323/4 "2017-03-20T09:24:31Z")

</div>

Just use the [search\_read](http://doc.tryton.org/4.2/trytond/doc/ref/models/models.html?highlight=read#trytond.model.ModelStorage.search_read) endpoint to read the data field and using  
[(‘resource’, ‘=’, ‘sale.sale,1’)] as [domain](http://doc.tryton.org/4.2/trytond/doc/topics/domain.html#topics-domain).

---

<div class="post-metadata">

### Author: ![piyush8191](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@piyush8191](https://discuss.tryton.org/u/piyush8191)
#### Post date: [March 20, 2017, 12:58pm UTC](https://discuss.tryton.org/t/how-to-get-add-attachment-of-sale-product-in-json/323/5 "2017-03-20T12:58:35Z")

</div>

ok, thank you for answer!

Also, can you let me know how to add attachment with any record?

Thank you,

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [March 20, 2017, 1:09pm UTC](https://discuss.tryton.org/t/how-to-get-add-attachment-of-sale-product-in-json/323/6 "2017-03-20T13:09:48Z")

</div>

> [@piyush8191](#):
>
> Also, can you let me know how to add attachment with any record?

You have to create a ir.attachment record with the resource field referencing the record.
