Jump to content

Problems with delete resources


batpeppe

Recommended Posts

HI,

I use Prestashop REST/API web service and I have a problem with deleting resources.

I was able to PUT AND POST just fine.

I try to delete a producer with DELETE with this XML

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<manufacturers>
<manufacturer>
<id>3</id>
<active>1</active>
<name>My Manufactory</name>
</manufacturer>
</manufacturers>
</prestashop>

ID 3 exists, but whatever ID I use the result is always the same

and I always get this response:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code><![CDATA[87]]></code>
<message><![CDATA[non-existent ID: 0]]></message>
</error>
</errors>
</prestashop>

 

Thanks in advance

Link to comment
Share on other sites

Hello,

The API web service follows the REST standards.

When you want to delete a resource, the request usually has the following structure: DELETE <api_base_url>/<resource>/<resource_id>

With these being said, you do not need to provide a body for it. You just need to provide the id in the URL. It should work fine at this point.

Link to comment
Share on other sites

Thanks Andrei for yuor answer,

I wrote a service with C# to connect to the PS Web Service and I need to send an XML with the resource to delete.
I use CRUD system to create, update or get data from web service

Can you give me an example of this request?

 

Thanks so much

 

Link to comment
Share on other sites

Hello,

If it's mandatory to send XML, it won't be a problem, you will not get an error. But the request body won't be taken into account for the delete request.

For deleting the manufacturer with the ID 3, you will need to send the following DELETE request: <your_webservice_url>/api/manufacturers/3 (you can send data in the body, but it won't be used). This should work as expected and the manufacturer should be deleted.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...