cancel
Showing results for 
Search instead for 
Did you mean: 

magento 2 how can i get invoice of order placed with rest api

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

magento 2 how can i get invoice of order placed with rest api

I am developing application using React-native an Magento as backend 
How can i get invoice of order placed with rest api i tried like this can any one help me

Screen Shot 2018-09-29 at 12.23.05 PM.png

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: magento 2 how can i get invoice of order placed with rest api

Hello @pratap_penmetsa,

 

Please below REST endpoint URL to generate invoice

 

Endpoint URL: http://magento.com/index.php/rest/V1/order/{order_id}/invoice
Request: POST
Header: Authorization bearer {access-token}}


I have also tried above Rest API, You can check result here https://www.screencast.com/t/xOCyjalmT

2018-10-03_10-35-49.jpg

 

After get invoice id, you can get invoice data by http://magento.com/index.php/rest/V1/invoices/{id} rest api, You can check more detail in my previous comment.

 

--
If my answer is useful, please Accept as Solution & give Kudos

View solution in original post

Re: magento 2 how can i get invoice of order placed with rest api

Hello @pratap_penmetsa

 

Have you tried with

 

rest/V1/order/{order_id}/invoice
Order_id param is required in this

 

If you want invoice data you can follow below API url:

rest/V1/invoices/{id}

Here id you will get from previous API.

 

If this is not working at your end then there is something different issue. 

Manish Mittal
https://www.manishmittal.com/

View solution in original post

11 REPLIES 11

Re: magento 2 how can i get invoice of order placed with rest api

 

Hello @pratap_penmetsa

 

are you using bundle products or parent products if yes this issue fixed in Magento 2.3 develop branch.

 

https://github.com/magento/magento2/issues/6988

Manish Mittal
https://www.manishmittal.com/

Re: magento 2 how can i get invoice of order placed with rest api

@Manish Mittal   can u help to get invoice for orders
which rest api should i use can u specify.

Re: magento 2 how can i get invoice of order placed with rest api

@pratap_penmetsa

 

Please use below API

rest/V1/order/order_id/invoice
Manish Mittal
https://www.manishmittal.com/

Re: magento 2 how can i get invoice of order placed with rest api

@Manish Mittal
I am using https://www.test.com/rest/V1/order/51/invoice. POST method.
51 is my order_id

I am sending body as below

{ "items": [ {"order_item_id": 51,"qty": 1} ] }

i am getting error response.
"message": "Invoice Document Validation Error(s):\nYou can't create an invoice without products.", what should i pass in body to generate invoice please help me. 

Re: magento 2 how can i get invoice of order placed with rest api

For your reference:

 

https://github.com/magento/magento2/issues/6988

 

Basically Magento has two different types of bundle products: dynamic and fixed. That's why I need to add clarification for Expected Result:
I) Bundle dynamic product:

  1. request:
    { "items": [ {"order_item_id": (parent bundle order_item_id), "qty": 1} ] }
    response:
    {"message":"InvoiceDocument Validation Error(s):\nYou can't create an invoice without products."}
  2. request:
    { "items": [ {"order_item_id": (child bundle order_item_id), "qty": 1} ] }
    response:
    partial id of created invoice

II) Bundle fixed product:

  1. request:
    { "items": [ {"order_item_id": (child bundle order_item_id), "qty": 1} ] }
    response:
    {"message":"InvoiceDocument Validation Error(s):\nYou can't create an invoice without products."}
  2. request:
    { "items": [ {"order_item_id": (parent bundle order_item_id), "qty": 1} ] }
    response:
    id of created invoice
Manish Mittal
https://www.manishmittal.com/

Re: magento 2 how can i get invoice of order placed with rest api

Hello @pratap_penmetsa,

 

Please below REST endpoints URL to get invoice data

 

Endpoint URL: http://magento.com/index.php/rest/V1/invoices/{id}
Request: GET
Header: Authorization bearer {access-token}}


I have also tried above Rest API, You can check result here https://www.screencast.com/t/8m6HdB5wl
2018-10-01_11-57-45.jpg

 

Let me know if you have any trouble in it.

--
If my answer is useful, please Accept as Solution & give Kudos

Re: magento 2 how can i get invoice of order placed with rest api

@gelanivishal

i have tried in this way but i am getting error please help me.  51 is my order_id

Screen Shot 2018-10-01 at 2.20.13 PM.png

Re: magento 2 how can i get invoice of order placed with rest api

Hello @pratap_penmetsa,

 

I have used invoice ID not order ID. Does it make sense? - Let me know if you get issue after using invoice id.

 

--
If my answer is useful, please Accept as Solution & give Kudos

Re: magento 2 how can i get invoice of order placed with rest api

Thanks for your reply, actually i am new to magento i don't know any thing about it, i am react native developer i am using magento as backend, After order is placed i am getting order_id only in response i am not getting any kind of invoice_id in response, how can i get invoice_id