Solved

Remove file using API


Userlevel 1
Badge

Hello. Im trying to remove image file from stock item using api.

Trying to process DELETE request to url 

/entity/Default/20.200.001/files/85c85649-8fbc-4a31-b8ce-5380ac3730fb

but getting an error “You are not logged in.”. But there is access token in request present and all other requests work fine. Could you help me with it? Thanks.

icon

Best answer by jinin 20 July 2022, 15:47

View original

15 replies

Userlevel 7
Badge +17

Hi @skater4  Have you logged in to the instance by making an API call like below?

 

 

Userlevel 1
Badge

Hi @skater4  Have you logged in to the instance by making an API call like below?

 

 

Seems to be yes 

Userlevel 7
Badge +11

Hi @skater4 

Did you try with GET or POST call? able to get success? Can you please check once?  If the connection is lost only we will get the logout message, You can log in the same like the above(Naveen shared screenshot)  request and try with Delete and Get calls

Userlevel 1
Badge

Hi @skater4 

Did you try with GET or POST call? able to get success? Can you please check once?  If the connection is lost only we will get the logout message, You can log in the same like the above(Naveen shared screenshot)  request and try with Delete and Get calls

Script processes stock update request right before the delete request, and its success

Userlevel 7
Badge +11

Hi @skater4 

Did you try with GET or POST call? able to get success? Can you please check once?  If the connection is lost only we will get the logout message, You can log in the same like the above(Naveen shared screenshot)  request and try with Delete and Get calls

Script processes stock update request right before the delete request, and its success

Hi @skater4 

As I know REST API doesn't support deletion of the files directly. You can create a custom page/screen showing the list of the attachments and work with that page from the REST API. Then try with the delete 

 

Userlevel 1
Badge

Hi @skater4  Have you logged in to the instance by making an API call like below?

 

 

Im authorizing via bearer token

Userlevel 1
Badge

Hi @skater4 

Did you try with GET or POST call? able to get success? Can you please check once?  If the connection is lost only we will get the logout message, You can log in the same like the above(Naveen shared screenshot)  request and try with Delete and Get calls

Script processes stock update request right before the delete request, and its success

Hi @skater4 

As I know REST API doesn't support deletion of the files directly. You can create a custom page/screen showing the list of the attachments and work with that page from the REST API. Then try with the delete 

 

U mean create GI and match it to endpoint?

Userlevel 1
Badge

Hi @skater4 

Did you try with GET or POST call? able to get success? Can you please check once?  If the connection is lost only we will get the logout message, You can log in the same like the above(Naveen shared screenshot)  request and try with Delete and Get calls

Script processes stock update request right before the delete request, and its success

Hi @skater4 

As I know REST API doesn't support deletion of the files directly. You can create a custom page/screen showing the list of the attachments and work with that page from the REST API. Then try with the delete 

 

U mean create GI and match it to endpoint?

Just tried, also not logged in

Userlevel 1
Badge

Also this topic says that REST API allows delete query  https://help.acumatica.com/(W(11))/Help?ScreenId=ShowWiki&pageid=04825ddc-c3af-49de-8663-ae119e84b987

 

Userlevel 7
Badge +11

Do you want to delete the file or a record?

The above one will help you to delete a record from the screen. 

can you please tell me which screen file you are trying to delete? 

Userlevel 1
Badge

Do you want to delete the file or a record?

The above one will help you to delete a record from the screen. 

can you please tell me which screen file you are trying to delete? 

Stock Item has attached images. I need delete all images of stock item by id. im obtaining image file ids when updating stock item and need to delete them

Userlevel 7
Badge +11

Do you want to delete the file or a record?

The above one will help you to delete a record from the screen. 

can you please tell me which screen file you are trying to delete? 

Stock Item has attached images. I need delete all images of stock item by id. im obtaining image file ids when updating stock item and need to delete them


You can insert files through REST API but Delete won't support it. 
 

 

Userlevel 1
Badge

Do you want to delete the file or a record?

The above one will help you to delete a record from the screen. 

can you please tell me which screen file you are trying to delete? 

Stock Item has attached images. I need delete all images of stock item by id. im obtaining image file ids when updating stock item and need to delete them


You can insert files through REST API but Delete won't support it. 
 

 

So no way to delete them in php script? 

Userlevel 7
Badge +11

Hi @skater4 
You can create a new screen with the list of images and create an endpoint entity for this screen then make an API call to delete the record. This will work.

Hi Team, 

  1. As suggested we created a new custom screen to bring order and files
     

     

  2. we also created custom endpoint for this custom screen
     

     

  3. through get call we are getting the order id and file ID
     

     

  4. using order ID we are able to delete the file
     

     

  5. But facing an issue, where if the order is having multiple files then using file ID we are not able to delete the respective file. But using id (order id - order note id) delete is happening but only one file is deleting.
  6. Can anyone help with this as how can we delete one single file, if the order is having multiple files

    Thanks & Regards,

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved