Jump to content

Web service - update product returns error 400 BAD REQUEST


encodia

Recommended Posts

I'm trying to update my products via web service (Prestashop 1.5.3.1).

I downloaded the PSWebServiceLibrary.php file and run the examples; after changing

 

const psCompatibleVersionsMax

 

to make it run with 1.5.3.1, I could run the examples.

 

I can read customers or products, but if I try to update one of them, I get a 400 error (Bad Request).

 

 

HTTP REQUEST HEADER

 

PUT /api/products/2 HTTP/1.1

Authorization: Basic RU5DUEhUUlZSR1hYR0xWVzFIM1QySFAyUjU4OEc0UTM6

Host: test.dev.loc

Accept: */*

Content-Length: 2474

Content-Type: application/x-www-form-urlencoded

 

 

 

 

HTTP RESPONSE HEADER

 

HTTP/1.1 400 Bad Request

Date: Tue, 22 Jan 2013 21:50:31 GMT

Server: Apache/2.2.22 (Unix) PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r

Vary: Authorization,Host

X-Powered-By: PrestaShop Webservice

Access-Time: 1358891431

PSWS-Version: 1.5.3.1

Execution-Time: 0.042

Set-Cookie: 3f99a2f33f7744ef0eca694ec6b1a644=MnNQK7%2BX8pQ%3DC%2FhkeW%2BSG98%3DeyWwe7MJMlE%3DJ82miKhnG%2Fg%3DFIUDljOoQlM%3DwCzdLGjYgV0%3D%2FzkZbA2Oumw%3DfAZdr7Dh2AA%3D000060; expires=Mon, 11-Feb-2013 21:50:31 GMT; path=/; domain=test.dev.loc; httponly

Content-Length: 241

Connection: close

Content-Type: text/xml;charset=utf-8

 

 

RETURN HTTP BODY

 

<?xml version="1.0" encoding="UTF-8"?>

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">

<errors>

<error>

<message><![CDATA[internal error. To see this error please display the PHP errors.]]></message>

</error>

</errors>

</prestashop>

 

 

What is the problem?

 

Is there another way to update products? I need to change prices with a batch process.

 

Thank you

Link to comment
Share on other sites

  • 2 months later...

I'm trying to update my products via web service (Prestashop 1.5.3.1).

I downloaded the PSWebServiceLibrary.php file and run the examples; after changing

 

const psCompatibleVersionsMax

 

to make it run with 1.5.3.1, I could run the examples.

 

I can read customers or products, but if I try to update one of them, I get a 400 error (Bad Request).

 

 

 

HTTP REQUEST HEADER

 

PUT /api/products/2 HTTP/1.1

Authorization: Basic RU5DUEhUUlZSR1hYR0xWVzFIM1QySFAyUjU4OEc0UTM6

Host: test.dev.loc

Accept: */*

Content-Length: 2474

Content-Type: application/x-www-form-urlencoded

 

 

 

 

 

 

HTTP RESPONSE HEADER

 

HTTP/1.1 400 Bad Request

Date: Tue, 22 Jan 2013 21:50:31 GMT

Server: Apache/2.2.22 (Unix) PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r

Vary: Authorization,Host

X-Powered-By: PrestaShop Webservice

Access-Time: 1358891431

PSWS-Version: 1.5.3.1

Execution-Time: 0.042

Set-Cookie: 3f99a2f33f7744ef0eca694ec6b1a644=MnNQK7%2BX8pQ%3DC%2FhkeW%2BSG98%3DeyWwe7MJMlE%3DJ82miKhnG%2Fg%3DFIUDljOoQlM%3DwCzdLGjYgV0%3D%2FzkZbA2Oumw%3DfAZdr7Dh2AA%3D000060; expires=Mon, 11-Feb-2013 21:50:31 GMT; path=/; domain=test.dev.loc; httponly

Content-Length: 241

Connection: close

Content-Type: text/xml;charset=utf-8

 

 

 

RETURN HTTP BODY

 

<?xml version="1.0" encoding="UTF-8"?>

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">

<errors>

<error>

<message><![CDATA[internal error. To see this error please display the PHP errors.]]></message>

</error>

</errors>

</prestashop>

 

 

What is the problem?

 

Is there another way to update products? I need to change prices with a batch process.

 

Thank you

 

Hi there

 

i also downloaded the PSWebServiceLibrary.php but i still get nothing in 1.5.3 can you please help me out and tell me what are the steps or pre requisite to run the web service .

 

what i get is 302 error.

Link to comment
Share on other sites

  • 1 year later...

I had the same issue with updating a product through PSWebServiceLibrary.php, here was the problem:

<message><![CDATA[parameter "position_in_category" not writable. Please remove this attribute of this XML]]></message>

If you enable debug on the library it gives you the HTTP responses required to track down the issue.

Edited by mohrt (see edit history)
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 7 months later...

same problem here (ps 1.6.0.14)

_PS_MODE_DEV_ = true not helping

 

I PUT very simple XML to change "active" only:

<?xml version="1.0" encoding="UTF-8"?><prestashop xmlns:xlink="http://www.w3.org/1999/xlink"><product><id>115880</id><active>0</active></product></prestashop>

and still have:

HTTP RESPONSE HEADER

HTTP/1.1 400 Bad Request

 

There is all OK with update the customer (with example file) but not with products.

Edited by stefan2 (see edit history)
Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

Thanks for the solution!

 

Running PS 1.6.0.9 here and had to remove the parameters "manufacturer_name" and "quantity"...

 

PS: I changed PS to debug mode in defines.inc.php:

define('_PS_MODE_DEV_', true);

It works! Thanks JoelPresta, you save my day!

 

;-)

Link to comment
Share on other sites

  • 2 years later...

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...