delete via API works a couple of times then dies  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

delete via API works a couple of times then dies

Postby JuiceyBrucey » Thu Nov 02, 2023 3:22 pm

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
Last edited by JuiceyBrucey on Thu Nov 02, 2023 3:37 pm, edited 1 time in total.
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

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

Postby Mike.Sheen » Thu Nov 02, 2023 3:25 pm

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
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

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

Postby JuiceyBrucey » Thu Nov 02, 2023 3:55 pm

**** 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
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

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

Postby Mike.Sheen » Thu Nov 02, 2023 4:04 pm

JuiceyBrucey wrote:**** sorry, originally put 403, but it was 401


A 401 means not authenticated. Are you using API Key authentication or Credentials authentication ?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

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

Postby JuiceyBrucey » Thu Nov 02, 2023 4:12 pm

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.
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

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

Postby Mike.Sheen » Thu Nov 02, 2023 4:14 pm

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

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

Postby JuiceyBrucey » Thu Nov 02, 2023 4:30 pm

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?
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

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

Postby Mike.Sheen » Thu Nov 02, 2023 4:48 pm

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

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

Postby SBarnes » Thu Nov 02, 2023 4:50 pm

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

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

Postby SBarnes » Thu Nov 02, 2023 4:52 pm

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
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 16 guests