Page 1 of 3

delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 3:22 pm
by JuiceyBrucey
7.2.1 SR 16
Hi, I have been using the JIWA API to do delete requests to the inventory using the Inventory/{InventoryId} method.
It worked perfectly a few times then started returning:
'content_type' => NULL,
'http_code' => 0,

I also used the same parameters through Postman, and it returned 401.
**** sorry, originally put 403, but it was 401.

Just some more info, all other requests are working fine.
Any idea what might be causing this?
Cheers

Re: delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 3:25 pm
by Mike.Sheen
JuiceyBrucey wrote:I also used the same parameters through Postman, and it returned 403.
Any idea what might be causing this?


A 403 indicates no permission. Check the permissions associated with the user/apikey

Re: delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 3:55 pm
by JuiceyBrucey
**** sorry, originally put 403, but it was 401
Other requests are working fine.

I have added Inventory/ DELETE to permissions admin group. Not sure if that is correct, but will look at tutorials to see if it is.
Cheers

Re: delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 4:04 pm
by Mike.Sheen
JuiceyBrucey wrote:**** sorry, originally put 403, but it was 401


A 401 means not authenticated. Are you using API Key authentication or Credentials authentication ?

Re: delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 4:12 pm
by JuiceyBrucey
I am using API Key.

I have followed the instructions on how to add route paths to admin user groups and settings appear to have updated.
But still no luck deleting item via API.

Re: delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 4:14 pm
by Mike.Sheen
JuiceyBrucey wrote:I am using API Key.


if you are getting a 401 with an API key then it's not permissions - the API key you are using is not valid - that is the only reason. Verify the key is correct and make sure the API is connecting to the right database.

Re: delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 4:30 pm
by JuiceyBrucey
Thank you for reply.
All other requests using the same API key are successful, so not sure why it would return 401 on postman.

Ok, so I tried doing it using the swagger.
This is the reply I got:

{
"ResponseStatus": {
"ErrorCode": "Exception",
"Message": "Can Not Delete. In use by : \r\n\r\nStock On Hand Transfer.\r\n",
"Errors": []
}
}

After seeing this, I found and instance on JIWA of this inventory item being open in the inventory form. I closed it and tried again, still no luck.
Is there something else I should be looking at?

Re: delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 4:48 pm
by Mike.Sheen
JuiceyBrucey wrote:All other requests using the same API key are successful, so not sure why it would return 401 on postman.


This indicates your Postman request does not have the API key set correctly - nothing mysterious - you've made a mistake in your Postman.

JuiceyBrucey wrote:Ok, so I tried doing it using the swagger.
This is the reply I got:

{
"ResponseStatus": {
"ErrorCode": "Exception",
"Message": "Can Not Delete. In use by : \r\n\r\nStock On Hand Transfer.\r\n",
"Errors": []
}
}

After seeing this, I found and instance on JIWA of this inventory item being open in the inventory form. I closed it and tried again, still no luck.
Is there something else I should be looking at?


That won't be a 401, that will be a different HTTP code. And the reason is exactly as stated - the inventory item is on a stock transfer document, so you can't delete it.

Again, nothing mysterious - just read the error.

Re: delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 4:50 pm
by SBarnes
The api is telling you why it can't do it once an inventory item has been transacted against (used in some way), you can't delete it inside Jiwa either.

It has been used in a stock transfer.

Re: delete via API works a couple of times then dies

PostPosted: Thu Nov 02, 2023 4:52 pm
by SBarnes
Mike.Sheen wrote:
JuiceyBrucey wrote:All other requests using the same API key are successful, so not sure why it would return 401 on postman.


This indicates your Postman request does not have the API key set correctly - nothing mysterious - you've made a mistake in your Postman.

JuiceyBrucey wrote:Ok, so I tried doing it using the swagger.
This is the reply I got:

{
"ResponseStatus": {
"ErrorCode": "Exception",
"Message": "Can Not Delete. In use by : \r\n\r\nStock On Hand Transfer.\r\n",
"Errors": []
}
}

After seeing this, I found and instance on JIWA of this inventory item being open in the inventory form. I closed it and tried again, still no luck.
Is there something else I should be looking at?


That won't be a 401, that will be a different HTTP code. And the reason is exactly as stated - the inventory item is on a stock transfer document, so you can't delete it.

Again, nothing mysterious - just read the error.


Snap