Jump to content

webservice adding new customer error


iJim

Recommended Posts

Hi to everybody.

I created a php file for add a new customer.

I followed the documentation, and i send a POST request, but i have an error

<error>
<code><![CDATA[127]]></code>
<message><![CDATA[XML error : String could not be parsed as XML

this is my source code:

    try {
        define('PS_SHOP_PATH',         '***');
        define('PS_WS_AUTH_KEY',     '***');
        define('PS_WS_DEBUG',         true);
        
        require_once( './PSWebServiceLibrary.php' );
        $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, PS_WS_DEBUG);

        $opt = array();
        $opt['url'] = PS_SHOP_PATH . '/api/customers?schema=synopsis';
        $opt['resource'] = 'customers';
        $xml = $webService->get($opt);
        $resources = $xml->children()->children();

        foreach ($resources as $key => $resource){
            $resources->$key = $_POST[$key];
        }

        $xmlstr = $xml->asXML();
        $opt = array('resource' => 'customers');
        $opt['postXml'] = $xmlstr;
        $xml = $webService->add($opt);

        echo '-- OK --';
        }

        catch (PrestaShopWebserviceException $ex) {
             ...
        }

Link to comment
Share on other sites

Now I've copied dispatcher.php from 1.6.0.8 and overrided 1.6.0.9

Now it's working :-) I won't say it's "[sOLVED]" as this is just a testing solution

 

Maybe there's a bug in dispatcher.php included in version 1.6.0.9

Let's play with diff tools :-)

 

Version 1.6.0.10? where are you?

 

Attached you'll finde dispacher from version 1.6.0.8

Please, be careful! backup everything! Not recommended for production environments!

dispatcher.zip

Edited by Wazzu (see edit history)
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...