I am creating an Invoice through Magento REST API with the below request:
POST "https://<magento-domain>/mg2/rest/V1/order/9/invoice"
Request Headers:
{
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer jnsptpdgsvmk5mrbctisi3e0yml7k6iu"
}
Request Body:
{
"capture": true,
"order_id": 9,
"items": [{
"order_item_id": 33,
"qty": 3,
"extension_attributes": {}
}],
"notify": true,
"appendComment": true,
"comment": {
"extension_attributes": {},
"comment": "Invoice#: 22",
"is_visible_on_front": 0
},
"arguments": {
"extension_attributes": {}
}
}
But I consistently get this error:
{
"message": "Consumer is not authorized to access %resources",
"parameters": {
"resources": "Magento_Sales::sales"
}
}
I am certain that the token I use works, because I am able to search orders and customers using the same token. The token is automatically renewed when I get a 401 error code in the response.
Also, the user I set up in Magento is an Administrator, which (I believe) has a full access on all objects (Sales Orders, Invoice, Shipments, etc.).
I have already configured the Integrations as well. So I am not sure what else I am missing?
Thanks in advance.